How to Install mod_rewrite

Posted on Thursday July 28, 2011 / by Eric Potvin

First, let's find where the mod_rewrite is located:

locate mod_rewrite.so

That will display the full path of where is located the file mod_rewrite.so

Then, create a new file for mod_rewrite:

sudo vi /etc/apache2/mods-enabled/rewrite.load

And add the following line:

LoadModule rewrite_module /path/to/mod_rewrite.so

Then edit /etc/apache2/sites-available/default (if that file is not found edit /etc/apache2/sites-available/000-default) and change the AllowOverride from None to All in the following configuration:

DocumentRoot /var/www
<Directory>
	Options FollowSymLinks
	AllowOverride None All
</Directory>

Final step, restart apache:

sudo /etc/init.d/apache2 restart

Now, you will have to start your head ache with mod_rewrite in your .htaccess file.