简体   繁体   中英

Not found comes out when laravel project moves to production server

When project is in local. This view can be seen from putting url "localhost/contact ". But When the project is in production server , "Not Found The requested URL /contact was not found on this server." Is displayed. How can I solve this problem. Thanks

Route::get('/contact', 'ContactController@index')->name('contact.index');

This could be due to many issues. I would suggest you to check whether your .htaccess is defined correctly and you have enabled mod_rewrite in your server. The method for this differs based on your server whether its Apache or Nginx. Follow the method suggested in the official documentation as in the image below.

文档截图

If you are using Apache server, don't forget to run the following commands to enable mod_rewrite and restart apache.

sudo a2enmod rewrite

sudo systemctl restart apache2

You can run a laravel project in two ways.

  1. php artisan serve (Development server)
  2. using apache server (localhost/project_folder/public/)

if you are using 2nd method(apache) try this.

sudo a2enmod rewrite

sudo service apache2 restart

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM