Enable mod_rewrite Apache2 on Debian 7

mod_rewrite installed by default on Apache2 installation,

Check verify the existence of /etc/apache2/mods-available/rewrite.load.

#cat /etc/apache2/mods-available/rewrite.load

LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

Enable and load mod_rewrite

#a2enmod rewrite

The above command will create a symbolic link in /etc/apache2/mods-enabled.

#ls -al /etc/apache2/mods-enabled/rewrite.load

lrwxrwxrwx 1 root root 30 Dec 7 05:26 /etc/apache2/mods-enabled/rewrite.load -> ../mods-available/rewrite.load

Then open and edit /etc/apache2/sites-available/default configuration. Replace every occurrence of “AllowOverride None” with “AllowOverride all”.

#vim /etc/apache2/sites-available/default

Finally, restart Apache2.

#service apache2 restart

Disable mod_rewrite Module in Apache2

To disable module use a2dismod command

#a2dismod rewrite

Finally, restart Apache2.

#service apache2 restart

Leave a Reply

Your email address will not be published. Required fields are marked *