mod_rewrite is enabled, but not working
Solution 1
You need to allow the overwrite.
<Directory "/path/to/document/root/">
AllowOverride All
</Directory>
Solution 2
First of all, set your httpd configuration to this (the path may differ with one another. In my ubuntu it's placed at /etc/apache2/sites-available/default):
DocumentRoot /var/www
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
After that, you should enable mod_rewrite with this command:
sudo a2enmod rewrite
The last one, restart your apache service:
sudo service apache2 restart
To ensure that, you can check it again from phpinfo in Configuration > apache2handler > Loaded Modules there must be written mod_rewrite
and it means mod_rewrite is enabled.
Solution 3
I had the similar problem, but the other answers did not helped me. This line at the begining of .htaccess
solved my problem:
Options +FollowSymLinks -MultiViews
Related videos on Youtube
Freddy Heppell
Updated on September 18, 2022Comments
-
Freddy Heppell over 1 year
I'm trying to get a PHP routing library set up. They give this example for a .htaccess file:
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L]
I couldn't get this to work, so I tried enabling mod_rewrite, but it says "Module rewrite already enabled".
Why is it not working properly? Thanks! I'm running Ubuntu Precise 12.04, and apache2.2.22. (Checked for any updates)
EDIT: A couple more details, it's a PuPHPet vagrant build, rewrite should be enabled.
-
Mark over 8 yearsThis is unnecessarily permissive. Only
AllowOverride
is necessary for the configuration in question.Allow from All
has nothing to do with the question and may not be appropriate for @randomdev's environment. -
Abhishek about 6 years
<Directory "/path/to/document/root/">
I forgot to change/path/to/document/root/
to my project root.Thanks! -
jjxtra almost 5 yearsShould this be in a virtual host element?
-
5d41402abc4 almost 5 yearsYou can see some example in Apache Virtual Host Example
-
Entretoize over 3 yearsThe only reply that helped me.
-
bxyify over 3 yearsThis did not help me either. Tried this and everything else and still got 404, a2enmod says module already enabled and I also have restarted my whole server a few times.