Laravel routes not working? Make sure .htaccess is working.

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 <Directory> directive

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

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

Simply change it to this:

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

Option 2) Add a <Directory> directive to your site's <VirtualHost> 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.

Secco Jones May 22, 2013

Thank you Pal, saved my day!

Mat May 31, 2013

The "RewriteBase" is important too.

For example :
Options +FollowSymLinks
RewriteEngine On
RewriteBase /my/folder/public

Ash Jun 28, 2013

Perfect, thanks for posting!

Geoff Oct 2, 2013

Thanks mate

Erik Oct 29, 2013

Great!

Sethathi Morokole Nov 24, 2013

Thanks man

ke20 Jan 10, 2014

Thank you very much :)

Xavier Feb 21, 2014

Thanks for this! Also as Mat mentioned, what was missing for me was the line

RewriteBase /~home/laravel_folder/public

in the .htaccess located in the "public" folder of Laravel

Bort Apr 1, 2014

You literally saved my life! Thank you.

Renato Theodoro Apr 25, 2014

Perfect!!!

Allan May 4, 2014

Thanks bro!

yeqingnan Jul 12, 2014

Perfect!!! Problem solved!

Derek Jul 18, 2014

I did all of this and it still won't work :/

Not sure why.

Added AllowOverride All to my httpd.conf

Added the 'RewriteBase' path as per the suggestions in the comments

restarted the server

Still getting 500 internal server error on my routes.

Brendan Aug 12, 2014

Thanks! Also, make sure mod_rewrite is enabled in your httpd.conf file.

Giacomo Oct 31, 2014

Perfect!
AllowOverride All solve my problem.
Thanks

theAmazingEngineer Nov 4, 2014

Mat's answer solve my problem.
"RewriteBase"
thanks for posting!

IamFace Nov 18, 2014

Thanks

Al Rogatto Nov 23, 2014

Thank you!
That was the problem!
Now I can keep going with Laravel. :)

najoua Dec 30, 2014

Thank u very helpful

Vahid Nov 21, 2015

Thanks/ worked on Ubuntu 15.10 ;-)

fahmi Jan 1, 2016

purrfect!

kamal Apr 24, 2016

very helpful great!

Lance Apr 24, 2016

Hello everyone,I'm not sure how option 2 is done. Could anyone tell me how to do this in details? Thank you so much!!!

mark Jun 30, 2016

Wish I'd found this 6 hours ago :-) Thanks for posting.

calojamatt Aug 17, 2016

it really help me. I was stuck. Thanks a lot for the post!!!

Daniel Sep 23, 2016

Thanks for this one - much useful. It was a first step in resolving my issues.

jack Nov 5, 2016

Mat thanks.

Chris May 9, 2017

Ive just come uploaded a laravel site to AWS after adding

AllowOverride All

i could go to the /images/logo.png and the logo was displayed
when i went too www.mysite.co.uk it gave a 500 internal error, after checking error logs i could see i needed to change the permissions on the storage directory

Leave a Comment