Thursday, May 23, 2013

Enable Mod_rewrite on Ubuntu (Apache2)

If you have .htaccess file with some rewrite rule that you need for your desire app.
But the rewrite rule is not working. There will be one of the reason is your mod_rewrite apache module is not enable or loaded. So you need to enable it.

For example, if you use a cms like wordpress,  permalinks for wordpress or another CMS is not working for same reason.

Now I am going to enable mod_rewrite apache module by using a simple command which is bellow

sudo a2enmod rewrite


This will enable mod_rewrite for apache2 in ubuntu. But we need to update Default apache2 config to AllowOverrides from .htaccess files or any rewrite rules created various cms like wordpress, joomla, drupal etc

Open the Default file by following command :

sudo gedit /etc/apache2/sites-available/default
 
Then looking the text "AllowOverride None" and changed it with "AllowOverride All" and restart apache by following command:

sudo service apache2 restart 

Mod_rewrite will enable now on ubuntu systemm runing on apache.

 

No comments:

Post a Comment