Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

3 Answers

up vote 9 down vote accepted

Try this sudo a2enmod rewrite then restart apache

share|improve this answer
    
It works. Thanks. –  Nathan Osman May 8 '10 at 6:28
add comment

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.

share|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. –  Nathan Osman May 8 '10 at 19:00
add comment

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

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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