Web development basic and advance tutorial, php basic tutorial, laravel basic tutorial, React Native tutorial

Wednesday, June 8, 2022

Laravel route error 404(Not Found) on CentOs7

0 comments

 

Laravel route error 404(Not Found) on CentOs7

 After a long period of time i found the issue with centos 7 laravel route not found issue.

in this tutorial i am going to explain you how you can face this problem issue. it not very difficult to fix this issue.

I created laravel project that work fine on my local windows pc. Once I upload to Centos7 server(via SSH), all my routes show 'Not Found 404, except index page. Picture below is my project structure. I remove public folder and place index.php outside.

 

  

 

 

 

Follow all this step so it will fix your all problem

 

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. 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>

3 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>

4 Restart httpd services

sudo service httpd restart

 

 

 

 

No comments:

Post a Comment