Back

Not found, but route exists.


Hi guys,

I've recently bought a digital ocean droplet and I've cloned my local version to the server. Everything works on localhost, but not on my server. The requested URL's are not found.. The URL's are all set in my routes.php and when I use "php artisan routes" they all show up..

Is this a common Laravel issue, or it is more a server thing?

siptik replied 3 years ago

Do you see your homepage or all pages are as 404 ?

evandertino replied 3 years ago

Have you configured your web server appropriately? If not so which one do you use Nginx or Apache

woogygun replied 3 years ago

Getting the same issue here, everything was running fine, adding new routes as i progressed and now all of a sudden the new routes are not being run. Even putting the route right at the top of the routes file does not run. If you run a:

php artisan routes

the route exists.

woogygun replied 3 years ago

woogygun said:

Getting the same issue here, everything was running fine, adding new routes as i progressed and now all of a sudden the new routes are not being run. Even putting the route right at the top of the routes file does not run. If you run a:

php artisan routes

the route exists.

Got it sorted with a

php composer.phar update

XoneFobic replied 3 years ago

Both woogygun and guiden, think it's useful if you paste the relevant code so we can take a look at it. Use http://bin.laravel.io for that.

To me it sounds like a .htaccess-like problem, or the server not 'pointing' to /public, mod_rewrite not active.

Dayle has some examples for apache, nginx and lighttpd on his Github repo

pescadosmith replied 3 years ago

Apache Web on Linux

My answer on stackoverflow: http://stackoverflow.com/a/24354757/2517465

1 Open httpd.conf

    sudo vim /etc/httpd/conf/httpd.conf

2 Make sure the DocumentRoot is pointing to the laravel project's public directory 3 Add the Directory element for that path and Allowoverride All... as follows

DocumentRoot "/var/www/html/laravel/public/"

<Directory "/var/www/html/laravel/public">
Allowoverride All
</Directory>

4 Open .htaccess from ../laravel/public/ and make sure it has the following

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

RewriteEngine On

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

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

5 Restart httpd services

sudo service httpd restart

6 Now http://DomainServer/users will work in your browser.

Haseeb90 replied 2 years ago

The thing with mine is that the '/' route is working but the others aren't ... why is that?

lagbox replied 2 years ago

check if rewrite is working

Haseeb90 replied 2 years ago

how to check that

Haseeb90 replied 2 years ago

I just ran the command sudo a2enmod rewrite and restarted apache but still no good

claratan replied 2 years ago

same problem here, '/' route is working but the others not work ! why ?

clayhenry replied 2 years ago

claratan said:

same problem here, '/' route is working but the others not work ! why ?

Make sure your .htaccess file is copied into your documentroot directory.

ironheartbj18 replied 2 years ago

I was following instruction by @pescadosmith my localhost is perfectly work when I am going to request URL or routes is not exist. the solved is to put add .000-default.conf

<VirtualHost *:80>
	
	
	ServerName www.van-vlymen.com
	ServerAlias van-vlymen.com
	
	ServerAdmin [email protected]
	DocumentRoot /var/www/html/vanvlymen/public
	
	<Directory /var/www/html/vanvlymen/public>
		Allowoverride All
	</Directory>

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

	
</VirtualHost>


inside the etc/apache2/000-default.conf.

it seems working now thanks you so much for added this!

mburakergenc replied 2 years ago

pescadosmith said:

Apache Web on Linux

My answer on stackoverflow: http://stackoverflow.com/a/24354757/2517465

1 Open httpd.conf

   sudo vim /etc/httpd/conf/httpd.conf

2 Make sure the DocumentRoot is pointing to the laravel project's public directory 3 Add the Directory element for that path and Allowoverride All... as follows

DocumentRoot "/var/www/html/laravel/public/"

<Directory "/var/www/html/laravel/public">
Allowoverride All
</Directory>

4 Open .htaccess from ../laravel/public/ and make sure it has the following

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

RewriteEngine On

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

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

5 Restart httpd services

sudo service httpd restart

6 Now http://DomainServer/users will work in your browser.

This worked for me!

ayelen117 replied 2 years ago

pescadosmith said:

Apache Web on Linux

My answer on stackoverflow: http://stackoverflow.com/a/24354757/2517465

1 Open httpd.conf

   sudo vim /etc/httpd/conf/httpd.conf

2 Make sure the DocumentRoot is pointing to the laravel project's public directory 3 Add the Directory element for that path and Allowoverride All... as follows

DocumentRoot "/var/www/html/laravel/public/"

<Directory "/var/www/html/laravel/public">
Allowoverride All
</Directory>

4 Open .htaccess from ../laravel/public/ and make sure it has the following

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

RewriteEngine On

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

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

5 Restart httpd services

sudo service httpd restart

6 Now http://DomainServer/users will work in your browser.

Thanks! This worked for me too.

johnathansantos replied 2 years ago

Enable mod_rewrite

sudo a2enmod rewrite
sudo service apache2 restart
ironheartbj18 replied 2 years ago

@johnathansantos

everything else are not working till i do the enable mod_rewrite

sudo a2enmod rewrite
sudo service apache2 restart

finally thank you

illuminate3 replied 1 year ago

johnathansantos said:

Enable mod_rewrite

sudo a2enmod rewrite
sudo service apache2 restart

This! solved it for me on a clean install box.

Thanks!

osumac24 replied 1 year ago

Perfect! This worked for me as well. Thank you!

pescadosmith said:

Apache Web on Linux

My answer on stackoverflow: http://stackoverflow.com/a/24354757/2517465

1 Open httpd.conf

   sudo vim /etc/httpd/conf/httpd.conf

2 Make sure the DocumentRoot is pointing to the laravel project's public directory 3 Add the Directory element for that path and Allowoverride All... as follows

DocumentRoot "/var/www/html/laravel/public/"

<Directory "/var/www/html/laravel/public">
Allowoverride All
</Directory>

4 Open .htaccess from ../laravel/public/ and make sure it has the following

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

RewriteEngine On

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

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

5 Restart httpd services

sudo service httpd restart

6 Now http://DomainServer/users will work in your browser.

andre replied 1 year ago

johnathansantos said:

Enable mod_rewrite

sudo a2enmod rewrite
sudo service apache2 restart

much love

isarastov replied 1 year ago

My routes were working for months and then suddenly I started getting 404 for every route, except the root one

<Directory "/var/www/html/laravel/public">
Allowoverride All
</Directory>

Adding this to apache2.conf solved the problem for me

jorwan replied 1 year ago

ironheartbj18 said:

@johnathansantos

everything else are not working till i do the enable mod_rewrite

sudo a2enmod rewrite
sudo service apache2 restart

finally thank you

This work for me too

lgalaz replied 1 year ago

did you get this sorted out?

also php mcrypt is required for laravel to work correctly.

if you are using homestead for local development then all that is taken care of.

I also think you should be using Nginx. https://www.digitalocean.com/community/tutorials/apache-vs-nginx-practical-considerations

in my opinion, its way easier to setup and i remember having a lot less problems with it. apache has its strengths, but for the things i currently do i dont see any benefits.

iboinas replied 1 year ago

johnathansantos said:

Enable mod_rewrite

sudo a2enmod rewrite
sudo service apache2 restart

Spot on! Thanks!

phpdevsami replied 1 year ago

lol i dont usually reply but thanks alot

ChrisHe replied 1 year ago

2 second check before doing the above, make sure you run ~~~$ composer dump-autoload~~~ as this rebuilds the static file

iamface replied 1 year ago

johnathansantos said:

Enable mod_rewrite

sudo a2enmod rewrite

I too just needed to enable mod rewrite. Thanks!

mahdimirhendi replied 1 year ago

pescadosmith said:

Apache Web on Linux

My answer on stackoverflow: http://stackoverflow.com/a/24354757/2517465

4 Open .htaccess from ../laravel/public/ and make sure it has the following

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

RewriteEngine On

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

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

5 Restart httpd services

sudo service httpd restart

6 Now http://DomainServer/users will work in your browser.>pescadosmith said:

Apache Web on Linux

My answer on stackoverflow: http://stackoverflow.com/a/24354757/2517465

1 Open httpd.conf

   sudo vim /etc/httpd/conf/httpd.conf

2 Make sure the DocumentRoot is pointing to the laravel project's public directory 3 Add the Directory element for that path and Allowoverride All... as follows

DocumentRoot "/var/www/html/laravel/public/"

<Directory "/var/www/html/laravel/public">
Allowoverride All
</Directory>

4 Open .htaccess from ../laravel/public/ and make sure it has the following

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

RewriteEngine On

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

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

And worked for me , thanks

gabykant replied 4 months ago

johnathansantos said:

Enable mod_rewrite

sudo a2enmod rewrite
sudo service apache2 restart

This saves my day. Thanks @johnathansantos

Lloric Mayuga Garcia replied 2 months ago

Maybe you created a route with the same uri,


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us