Rambles and Riff Raff about all this and that
Activating mod_rewrite on Apache @ Ubuntu
Published by Esteban Glas on June 20th, 2007 | This post lacks all category except for: Linux, Servers and configs
I can usually find my way through Server configuration files fairly easy, but upon installing a LAMP server on Ubuntu I noticed “mod_rewrite” wasn’t working at all. The answer ended up being fairly simple, once you know where to look, but for others not to struggle as I did I’ll post what and where to look.
Ubuntu’s Apache is quite modularized; both in packages and in runtime senses. This has several advantages which I wont mention here, but forces you to edit several configuration files to make adjustments.
Here’s the ABC to it:
- Add a loader to mod_rewrite module:
Execute (on the shell):
sudo a2enmod rewrite - Edit the apache2.conf by adding a call:
On ubuntu this file usually sits on: /etc/apache2/apache2.conf
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>
Note: you can also add this on the .htaccess files. - Edit the virtual host file:
To know what hosts are enabled take a look at:
/etc/apache2/sites-enabled/
There you’ll see a simlink to some file(s) sitting at:
/etc/apache2/sites-available/
which you’ll have to edit.
You need to add the permissions for your directorie(s):
<Directory />Note: you can set this values for the root directory (as in this example) or for just 1 or more folders / sub-folders.
Options FollowSymLinks
AllowOverride All
</Directory> - Restart your Apache:
sudo /etc/init.d/apache2 force-reload
or
sudo apache2ctl restart
That should do the trick!



June 20th, 2007 at 3:57 pm
Esteban,
I think this post is a valid example of the prior discussion on resume blogging. You’ve just screamed, “I’m a very technical guy” who’s savvy on the lattest trends LAMP servers for hosting.
Kudos.
June 20th, 2007 at 8:18 pm
Thanks Mark, Actually I usually use the Internet as my bookstore, when I face a problem I can’t solve I google around in search of answers.
This particular case was one of the handful where I could not find the appropriate answers. Thus I thought it would be nice to post the resolution just in case I could make any other poor soul’s life less miserable.
June 22nd, 2007 at 6:07 pm
Just wanted to let you know that engine is spelled wrong above and will cause an error in loading.
June 22nd, 2007 at 11:18 pm
Thanks for the catch Justin, fixed!!
July 11th, 2007 at 6:29 pm
Just installed Ubuntu 7.04 server and this was just what the doctor ordered. Can’t understand why mod_rewrite isn’t there by default. Thanks for these easy to follow instructions.