php – Not found comes out when laravel project moves to production server-ThrowExceptions

Exception or error:

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');
How to solve:

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.

Screenshot of Documentation

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

Answer´╝Ü

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

Leave a Reply

Your email address will not be published. Required fields are marked *