How to enable mod_rewrite for Apache in Ubuntu
It’s already installed, but not enabled. The easiest way to enable it is to follos these steps:
- run this command (a2enmod == apache2 enable module):
a2enmod rewrite
- edit this file /etc/apache2/sites-enabled/000-default; you can use the following command:
sudo gedit /etc/apache2/sites-enabled/000-default
- 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>
- 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.
I cannot run a2enmod. I got this message :
bash: a2enmode: command not found
what’s wrong?
I think you typed “a2enmode” instead of “a2enmod”
also, check this out: http://ubuntuforums.org/showpost.php?p=2519487&postcount=3
ooo shit! that’s my bad… thank you