13

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.

20

Try this: sudo a2enmod rewrite, and then restart apache.

4

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. :)

  • Well, it's just for local testing, so not a big deal. But ya, a2enmod is just easier anyway. – Nathan Osman May 8 '10 at 19:01
2

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.

  • That works too. Just remember to set the right permissions on the symlinks in mods-enabled... or you will be pulling your hair out. – Nathan Osman May 8 '10 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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