Lucas Serafim
Lucas Serafim

Reputation: 3832

Laravel css/js gives 404 but the files exist

I'm working in a admin bundle but the css/js is not working. http://d.pr/i/UJHo

From the print, bootstrap js/css came from external domain, I tried to call a local bundle file but I got the error. My htaccess is unchanged from original laravel: http://d.pr/i/VWua

Tip: When I access http://domain/img/bg.png that's works, but not when I try http://domain/images/bg.png

Upvotes: 2

Views: 6574

Answers (2)

Gilberto Albino
Gilberto Albino

Reputation: 2744

I think you should improve your .htaccess file.

I suggest using this:

RewriteEngine On
RewriteRule !\.(js|gif|jpg|png|css|txt)$ public/index.php [L]
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ public/$1 [NC,L]

That works pretty fine for me.

Upvotes: 1

Collin James
Collin James

Reputation: 9310

It looks like you are rewriting /images to /public/img. 'public' is the webroot so presumably the request is going to /public/public/img...

But it looks like these rules aren't being applied at all because the /img path would have the same issue. Check the body of the 404 response. If it contains HTML for the 404 page returned by Laravel then this is the case.

Either way those lines are not really needed. If you want /images to return stuff in /public/img, then you should create a symlink from /public/images to /public/img.

Upvotes: 1

Related Questions