A user recently requested information on enabling mod_rewrite for Apache. They were trying to configure WordPress to use permalinks. Fortunately for us, there are two ways to enabled mod_rewrite and they are really simple. First, we will assume that you have Apache2 installed as your web server. Before we get started, if you are looking for a how-to setup Apache/WordPress then you can follow this screencast for a walk through of the process.

Here is the first method to enable mod_rewrite so our WordPress permalinks work as we would like them too; this is for Debian/Ubuntu servers.

Ssh into your instance and type at the console :~$ sudo a2enmod rewrite
Once this is completed we must restart Apache to apply the changes.
Type :~$ sudo /etc/init.d/apache2 restart

If you look at the a2enmod command it’s rather simple. a2enmod = Apache2 Enabled Mod

The a2enmod command actually moves the Apache module files from /etc/apache2/mods-available to /etc/apache2/mods-enabled.

The second method is to manually move the module files ourselves. Here’s how we accomplish this task:

:~$ sudo mv /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/
:~$ sudo /etc/init.d/apache2 restart

The first method is the preferred and right method to do this. So if at all possible stick with that method.

Get actionable training and tech advice

We'll email you our latest articles up to once per week.