Linux Stuff && Coffee

Enable Mod_rewrite on Ubuntu (Apache2)

| Comments

If your permalinks for wordpress or another CMS are not working on Ubuntu then you will need to follow this guide. To enable mod_rewrite on Ubuntu enter the following command with root permissions.

Enable mod_rewrite Ubuntu

sudo a2enmod rewrite

This will enable mod_rewrite for Apache2 on Ubuntu but we need to edit the default Apache2 config to AllowOverrides from .htaccess files or any rewrite rules created by various CMS’s (wordpress, drupal, etc) will be ignored.

Open the following file default apache2 config file on Ubuntu:

sudo vi /etc/apache2/sites-available/000-default

(Obviously you can use whatever editor you like, if you need help check out our vi commands cheat sheet.

Look for the following text “AllowOverride None” and change it to “AllowOverride All” ad restart Apache with:

service apache2 restart

Mod_ReWrite will now be enabled on Ubuntu systems running Apache2.