laravel the requested url was not found on this server
Stefan Izdrail
Founder & Senior Architect · 2026-06-29
Laravel is a powerful PHP framework that enables you to develop web applications quickly and efficiently. One of the most common issues faced by developers when deploying their Laravel-based websites on Ubuntu servers is the "Not Found" error (404) when trying to access specific URLs like /login or other custom routes. This blog post will provide a comprehensive guide to help you understand and resolve this issue so that your Laravel application runs smoothly on your Ubuntu server.
Ensure Correct Document Root Configuration
The first step in resolving the issue is to check if the virtual host configuration for Apache is correctly set. Open the file /etc/apache2/sites-available/000-default.conf and ensure that the DocumentRoot path matches your Laravel application's public folder:
DocumentRoot /var/www/html/public/
Verify Your Routes Are Configured Properly
Ensure that your routes.php file or Laravel's default routing mechanism is set up correctly. The application should be able to find and process the appropriate route for the requested URL. For instance, if you need access to a specific page like /login, you will define a corresponding route in your routes file:
Route::get('/login', function () {
return view('auth/login');
});
Verify the Routing Configuration Is Applied Correctly for Apache
Once you have verified that the routing is appropriately defined, you need to ensure your Apache configuration file (000-default.conf) is set up to use Laravel's public folder as the base URL. If you have changed your DocumentRoot path to /var/www/html/public/, update the VirtualHost section of 000-default.conf accordingly:
DocumentRoot /var/www/html/public/
Enable Mod Rewrite in Apache Configuration File
In some cases, mod_rewrite might be disabled by default on your Ubuntu server. To enable this module, you can use the following commands:
sudo a2enmod rewrite
sudo systemctl restart apache2
Check Your .htaccess File for Correct Rewrite Rules
The .htaccess file in the public folder is responsible for handling incoming URL requests. Ensure that it includes Laravel's default rewrite rules, such as:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
Clear Your Browser's Cache and Check for Other Issues
Sometimes, even if the configuration is correctly set up, you may still experience problems accessing your Laravel routes. In such cases, try clearing your browser's cache or using an incognito window to avoid any potential caching issues that might prevent the server from displaying the correct page.
Conclusion
By following these steps and setting up a proper Laravel application configuration on your Ubuntu server, you should be able to access all of your custom routes without encountering any "Not Found" errors. If the problem persists, ensure that your Laravel application is installed correctly and the various components are in their proper places. If necessary, reach out for further assistance or consult with a professional team like Laravel Company.
Troubleshooting Steps
- Ensure your DocumentRoot path is configured correctly in the Apache virtual host configuration file
- Verify your Laravel routes are defined properly and match the requested URLs
- Enable mod_rewrite on your Ubuntu server, if needed
- Check your .htaccess file for proper rewrite rules
- Clear your browser's cache or use an incognito window to prevent caching issues from interfering with the page rendering
- Make sure your Laravel installation files are in place and organized correctly
- Reach out for professional assistance, if necessary (Laravel Company's contact page: https://laravelcompany.com/contact)