The Page Not Found error generally found when your application can not find the required route in your application or website. Following are few common steps to resolve this error.
1. Check Route Definitions
Make sure that the route you are trying to access is defined in the file called routes/web.php
or routes/api.php
(for API routes) file.
Use the required and correct HTTP method (GET, POST, etc.). into your application for routes:
Route::get('/your-route', 'YourController@yourMethod');
2. Run php artisan route:list
Run php artisan route:list in your terminal.It will display all registered routes. Check if your route appears in the list. If it doesn’t, there might be a typo or the route definition is missing.
3. Clear Route Cache
Laravel caches routes in production mode, which can sometimes cause routing issues. Clear the cache by running the following command :
php artisan route:clear
After running the command, try accessing the route again.
4. Check Controller and Method
Check the controller and method name referenced in the route file.
5. Correct Web Server Configuration
Check your .htaccess file in the public folder that should be correct.
6. Check your htaccess file
You need to check htaccess file and put following code.
<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>
Ravindra is a passionate full stack developer and dedicated blogger with a flair for crafting user-friendly web applications and insightful articles. With expertise spanning front-end and back-end technologies, Ravindra brings ideas to life through innovative coding solutions.