Enabling mod_rewrite in Apache2 (LAMP)

mod_rewrite is a module in Apache which is used to simply rewrite a URL into a different URL. This module comes by default with Apache2. If you are using Apache in a Windows environment, simply right clicking on the Wamp server icon and enabling mod_rewrite from there would do. But in a Linux environment, these are the simple steps to follow.

Issue the following command to enable the module.

a2enmod rewrite

The command a2enmod can be used to load this kind of modules to Apache.

Chances are that you would still not be able to  have URL rewrites. For this you must change some settings in another conf file.

Go to /etc/apache2/sites-available/ and open the file default. Replace every “AllowOverride None” with “AllowOverride All“. This enables Apache2 to override rewrites by the use of .htaccess files.

Restart the server and rewrites should be working fine for you.

/etc/init.d/apache2 restart

Comments are closed.