Laravel Routes not working, Apache configuration only allows for public/index.php/route
Two most common causes of this behavior are:
mod_rewrite not enabled
sudo a2enmod rewrite && sudo service apache2 restart
AllowOverride
is set to None, set it to All, assuming Apache2.4sudo nano /etc/apache2/apache2.conf
search for <Directory /var/www/>
and change AllowOverride None
to AllowOverride All
, then save the file and restart apache
Do you have mod_rewrite installed and enabled on apache? Try to remove the if lines ( and ) and see if it throws an error when you try to load the website. If it does, run sudo a2enmod rewrite
and restart apache.
This is the .htaccess I have on my public/ directory:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Changing AllowOverride None
to AllowOverride All
and sudo a2enmod rewrite && sudo /etc/init.d/apache2 reload
did help.