How to enable Apache mod rewrite in Ubuntu

Actually this probably works for all Linux distributions with Apache 2. Okay enabling mod_rewrite is really easy, you just have to use a2enmod (Apache 2 enable module):

[code lang=”bash”]sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart[/code]

To disable an Apache 2 module, you can run:

[code lang=”bash”]sudo a2dismod rewrite
sudo /etc/init.d/apache2 restart[/code]

That does the reverse.

With mod_rewrite enabled, you can use the .htaccess file.

By the way in your directory permissions, you must set AllowOverride to “all” like this:

[code lang=”ini”]
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all

Hope it helps.