Skip to main content

Enabling Mod Rewrite On Apache2

Posted on January 24, 2012 by Anthony James Founder/CEOAnthony James Founder/CEO

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.


Image of jaffe
8 years ago

Excellent. Thank you for the help.

Image of Brandon
7 years ago

I get this error.
sudo: a2enmod: command not found

Image of Anthony James Founder/CEO
Anthony James Founder/CEO
7 years ago

That tells me your running a centos or redhat. Which you have to manually enabled the module in the apache conf.


Leave a Reply

Your email address will not be published. Required fields are marked *