Select a Category

How to Enable Mod_Rewrite in Ubuntu


There are several packages require mod_rewrite for Apache2. I had problem to enable it for a long time. I could not find a clean answer on how to do it.

PHPInfo does not show Mod_Rewrite module

Finally, I figured it out. Here are the steps.

Enable Mod_Rewrite Steps:

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

<NameVirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
<Directory />

Options FollowSymLinks
# AllowOverride None          #Original Line
# New Line
AllowOverride All
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
# AllowOverride None #Original Line
# New Line
AllowOverride ALL
Order allow,deny
allow from all

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: a2enmod rewrite

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

PHPInfo shows mod_write Module

Comments are closed.