0

Ya'all are my last chance to somehow solve this issue that's been stalling me for the past 2 weeks and I have not managed to find an answer.

I have my website hosted on Hostinger with Laravel 5.1 installed.

I'm trying to link my css files from the public/css folder but I always get net::ERR_ABORTED error when it's trying to load the files.

My /public/.htaccess file is as follows:

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ / [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(css|js|images)/(.*)$ public// [L,NC]
RewriteRule ^ index.php [L]

RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

The one from the root is as follows

Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteRule ^ index.php [L]

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

RewriteRule ^(.*)$ public/ [L]

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ / [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

RewriteRule ^(css|js|images)/(.*)$ public// [L,NC]
</IfModule>

I've tried linking the css files with all of these ways

<link type="text/css" rel="stylesheet" href="{!! asset('/css/style.css') !!}">

<link type="text/css" rel="stylesheet" href="{{ asset('/css/style.css') }}">

<link type="text/css" rel="stylesheet" href="{!! asset('css/style.css') !!}">

<link type="text/css" rel="stylesheet" href="{{ asset('css/style.css') }}">

{!! Html::style('css/style.css') !!}

{!! Html::style('/css/style.css') !!}

<link type="text/css" rel="stylesheet" href="/css/style.css">

<link type="text/css" rel="stylesheet" href="css/style.css">

None has proved to work and I honestly see no other way to actually link and use the css files I have. I'm stuck on this and I'm actually desperate to find a way to make it work.

All of the css/js files are in /public/css/ or /public/js/

Help a coder out 'cuz I feel like just quitting this. I don't know if the .htaccess files are somehow restricting the acces or what is happening.

Cheers, G.

George
  • 35
  • 6
  • do the js files work? can you save laravel index.php in another folder .. and add a simple index.php in its place (for testing purposes) including pure html with the css linked and check the results? – Hamza Mohamed Mar 10 '18 at 18:17
  • access the direct link to the file in the browser and let me know if that works. – StealthTrails Mar 10 '18 at 18:26
  • @HamzaMohamed results are the same, so the blade extension is not the problem – George Mar 10 '18 at 18:39
  • @Adamnick - I can't access the css files like that :) i'm getting the standard laravel "Page not found" – George Mar 10 '18 at 18:40
  • What is your pubic folder permissions? – Hamza Mohamed Mar 10 '18 at 18:43
  • drwxrwxrwx for the public folder - I did a chmod 777 -R on it to make sure it has all the rights. – George Mar 10 '18 at 18:45
  • can give extra information on how is laravel folders added? is it added to the public_html or are you using vps? which tutorial did you follow? – Hamza Mohamed Mar 10 '18 at 18:55
  • I'm using the normal hosting services, I used the website installer provided by Hostinger that installed Laravel 5.1.11 on the website. Yes, it is added to the public_html folder and the structure is the standard laravel one. – George Mar 10 '18 at 18:59
  • access like this website.com/public/css/style.css – StealthTrails Mar 10 '18 at 19:01
  • @Adamnick Doesn't work - i get "Sorry, the page you are looking for could not be found." for website.com/public/css/style.css and website.com/css/style.css – George Mar 10 '18 at 19:05
  • Remove `RewriteRule ^(css|js|images)/(.*)$ public// [L,NC]`. – ako Mar 10 '18 at 19:14
  • @ako Same issue sadly :( this rule i've added recently after trying other things to see if the .htaccess file might be the problem (i don't know much about how it works) – George Mar 10 '18 at 19:17
  • Somehow i'm sure the problem is in `.htaccess` file, But don't know what part of it exactly, I had same issues with `.htaccess` file. Try to clear the content of `.htaccess` file in `public` folder and put the content suggested by laravel documentation for apache [here](https://laravel.com/docs/5.1#configuration) and remove `.htaccess` file in root of your project. – ako Mar 10 '18 at 19:21
  • @ako I think so also, but it's not the case here... this change actually broke the site and I could no longer access it. I'm getting a blank view – George Mar 10 '18 at 19:30
  • U mean with this changes returning views does not work? Why site must break? – ako Mar 10 '18 at 19:33
  • Yep :) I tried a fresh install of laravel with a basic public/css/style.css that changes the

    to color red and the error persists. So i'm all out of ideas.
    – George Mar 10 '18 at 19:41
  • Restart your web server. – ako Mar 10 '18 at 19:41
  • I have no idea how to do that on a shared web server, the website is hosted on Hostinger :) i don't think those guys would allow me to restart their webserver. – George Mar 10 '18 at 19:49
  • That's definitely .htaccess issue .. you would better check server fault or ask Ubuntu or Unix&Linux.. or even better get a vps for 2.5 @ vultr or $5 @ digital ocean .. or the best offer which is $10~12 @ SSD nodes – Hamza Mohamed Mar 11 '18 at 17:31

0 Answers0