How do you enable mod_rewrite with Apache in Ubuntu 10.04?

I tried copying rewrite.load from /etc/apache2/mods-available to etc/apache2/mods-enabled but that didn't work.

link|improve this question

79% accept rate
feedback

3 Answers

up vote 6 down vote accepted

Try this sudo a2enmod rewrite then restart apache

link|improve this answer
It works. Thanks. – George Edison May 8 '10 at 6:28
feedback

Actually, while being the kind of wrong solution, copying rewrite.load from ./mods-available/ to ./mods-enabled/ should have worked. Did you remember to restart your apache afterwards?

In any case, ./mods-enabled/ should usually contain symlinks to corresponding files in ./mods-available/. This is, as mentioned by Obsidian, easiest handled by the commands a2enmod and a2dismod.

Apart from enabling the module, you will also have to activate the rewriting. Before you can write your RewriteCond:s and RewriteRule:s there has to be a "RewriteEngine On" in that configuration context.

link|improve this answer
That works too. Just remember to set the right permissions on the symlinks in mods-enabled... or you will be pulling your hair out. – George Edison May 8 '10 at 19:00
feedback

Obsidian's answer to use a2enmod is the proper solution. andol's method would work, but could break on upgrade. What a2enmod does is simply create a symbolic link, so the following two are the same, both proper, solution:

  ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/

or

  a2enmod rewrite

However, a2enmod will look for other types of files, some have .conf and possibly others. There's no reason not to learn this command, though it's important to know what is going on in the background.

Copying the file would make any future admin very unpleased with you. :)

link|improve this answer
Well, it's just for local testing, so not a big deal. But ya, a2enmod is just easier anyway. – George Edison May 8 '10 at 19:01
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.