Technical stuff Requirements are like water. They're easier to build on when they're frozen.

How to enable mod_rewrite for Apache in Ubuntu

05.21.2009 · Posted in Computer setup

It’s already installed, but not enabled. The easiest way to enable it is to follos these steps:

  1. run this command (a2enmod == apache2 enable module):
    a2enmod rewrite
  2. edit this file /etc/apache2/sites-enabled/000-default; you can use the following command:
    sudo gedit /etc/apache2/sites-enabled/000-default
  3. make sure you have there AllowOverride All directive for the default directory (this will make all the subdirectories inherit this behaviour):
    DocumentRoot /var/www
    	<Directory />
    		Options FollowSymLinks
    		AllowOverride All
    	</Directory>
    	<Directory /var/www/>
    		Options Indexes FollowSymLinks MultiViews
    		AllowOverride All
    		Order allow,deny
    		allow from all
    	</Directory>
    
  4. restart apache and enjoy!
    sudo /etc/init.d/apache2 restart

Note: I use gedit because it’s my home desktop computer. On a server where you have no graphical interface at your disposal (and no gedit for that matter), you can safely use you favorite editor (nano, pico, vi) so all you have to do is replace

sudo gedit

with

sudo nano

if your favorite is nano.

3 Responses to “How to enable mod_rewrite for Apache in Ubuntu”

  1. I cannot run a2enmod. I got this message :

    bash: a2enmode: command not found

    what’s wrong?

  2. I think you typed “a2enmode” instead of “a2enmod”

    also, check this out: http://ubuntuforums.org/showpost.php?p=2519487&postcount=3

  3. ooo shit! that’s my bad… thank you

Leave a Reply