jpeterson579's avatar

Image URLs giving NotFoundHttpException in RouteCollection.php line 161:

This is so strange. So im using Laravel 5.3 and in my blade file i reference images like this:

<img src="{{ url('images/bg/background-image.jpg') }}">

which on my local host returns a url of http://localhost:8888/images/bg/background-image.jpg and it works!

However when i push this to my live site and view it, the url that the link gives me is http://myipaddress/images/bg/background-image.jpg which does not show the image. If i go directly to the image URL i get the following error.

NotFoundHttpException in RouteCollection.php line 161:

Anyone have an idea whats going on?

0 likes
6 replies
Snapey's avatar

something wrong with your .htaccess file?

image requests should not be hitting your router

spekkionu's avatar

Did you verify that the image exists in the correct directory on the live server?

jpeterson579's avatar

@snapey dont see anything strange in my htaccess

<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 ^(.*)/$ /$1 [L,R=301]

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

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

@ejdelmonico whats the point of the slash at the beginning. The url of the image that is showing up on my live site is correct, its just saying the file is not there.

@spekkionu Yes i have checked this 10 times thinking im crazy. The file is in the folder which is in my public folder. public/images/filename.png

jpeterson579's avatar
jpeterson579
OP
Best Answer
Level 7

And in writing this post I compared the permissions of the folders which were all wrong! Whoops..

Ishatanjeeb's avatar

Please change the permissions of the yourProjectRoot/images directory to allow the web group write permissions.

Please or to participate in this conversation.