Reputation: 31
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I tried this code snippet for URL rewrite and it is not working.
Upvotes: 0
Views: 1953
Reputation: 13703
According to me your public/.htaccess file should be like:
<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>
Also please check that you've enabled mod rewrite in your apache via editing php.ini & httpd.conf file.
You can also follow these steps (Link) to make your mod_rewrite URLs work
Don't forget to restart the Apache Service after doing this.
sudo apachectl restart // For MacOS
sudo service apache2 restart // For Ubuntu
Upvotes: 1