How can I fix Laravel 5.1 - 404 Not Found?

If you are running Apache HTTPD 2.2.15 on Linux (CentOS 6.7 in my case), then the directory directive will look like this

<Directory />
    Options Indexes FollowSymLinks Includes ExecCGI  
    AllowOverride All  
    allow from all  
</Directory>  

You probably don't need the Options line though, unless you're using those options.

Thank you to the 2.4 answer. It helped me solve this issue for me on 2.2 and I have another server running 2.4 I can apply it to too.


if you are on ubuntu you shoud do 3 thing. 1. check if "/var/www/html/YourProject/public/ .htacess " is like this.

<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}]

2. Add this lines on /etc/apache2/sites-available/000-default.conf

<Directory "/var/www/html">
 AllowOverride all
 Require all granted
</Directory>

Note: remember that is an system file so you should use this comamd

sudo gedit /etc/apache2/sites-available/000-default.conf 
  1. by last enable rewrite module.

    LoadModule rewrite_module modules/mod_rewrite.so

or

sudo a2enmod rewrite

I see the same behaviour of being able to visit the / route but all other pages return a 404 when I first setup Laravel sites.

In your apache config file httpd.conf or httpd-vhosts.conf you need to enable the directives that can be placed in the .htaccess file.

Here is an example of my VirtualHost configuration:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "C:/www/laravel_authority-controller_app/public"
    ServerName authoritycontroller.www
    ErrorLog "logs/AuthorityController.www-error.log"
    CustomLog "logs/AuthorityController.www-access.log" common
    <Directory "C:/www/laravel_authority-controller_app/public">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks Includes ExecCGI

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
    </Directory>
</VirtualHost>

The key entry for your issue is AllowOverride All. This should be enough to get the website working but you can also include options and Require all granted if they are consistent across the entire website.


If your Laravel routes aren't working, and you're getting "Not Found" errors whenever you try and load a page, your .htaccess file is likely lacking permission to do its duty.

The key is the apache AllowOverride directive.

If you don't have AllowOverride set to All, your Laravel .htaccess file (/public/.htaccess) won't be able to enable mod_rewrite, and your routes won't work.

The first step is to open your apache httpd.conf file. In OS X, it is located at:

/private/etc/apache2/httpd.conf

Option 1) Modify your main directive

This will change the AllowOverride value for all your websites. In your httpd.conf file, look for the main directive:

<Directory "/var/www/html">
    ...
    AllowOverride None
    ...
</Directory>

Simply change it to this:

<Directory "/var/www/html">
    ...
    AllowOverride All
    ...
</Directory>

Option 2) Add a directive to your site's directive.

<VirtualHost 127.0.0.1:80>
    DocumentRoot "/var/www/html/epigroove/public"
    ...
    <Directory "/var/www/html/epigroove/public">
        AllowOverride All
    </Directory>
</VirtualHost>

Save the changes to your httpd.conf file, restart or reload apache, and your routes should be up-and-running.