Introduction:

There are several packages I used require Apache2 module mod_rewrite. I had problem to enable it for a long time. I could not find a clean answer on how to do it. Finally, I figured it out. Here are the steps. Here is a screen shot of the phpinfo.php

PHPInfo without mod_write Module

Enable Mod_Rewrite Steps:

1. Edit /etc/apache2/sites-available/default. Changed “AllowOverride None” to “AllowOverride All” in the two places below.

NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
# AllowOverride None    #Original Line
# New Line
AllowOverride All
</Directory>

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
# AllowOverride None    #Original Line
# New Line
AllowOverride ALL
Order allow,deny
allow from all
</Directory>
….
2. Edit /etc/apache2/sites-enabled/000-default. Changed “AllowOverride None” to “AllowOverride All” in the two places shown above as well.
3. Enable mod_rewrite with the following command: a2enmode rewrite

4. Force reload the apache2 server with:  sudo /etc/init.d/apache2 force-reload

Now if you load the phpinfo.php, you can see that mod_rewrite is enabled.

PHPInfo shows mod_write Module