How to enable mod_rewrite in Ubuntu 14.04 and 12.04 LTS

Thursday, September 18, 2014 govindkewat.com 0 Comments


Here I am back to guide you how to enable mod_rewrite in ubuntu 14.04 & 12.04 LTS. A little note this is the basic steps to enable mod_rewrite but not the best way. Best way is to setup virtual host first and make changes in that config.
Read my previous blog to learn How to install & configure apache in ubuntu.

Ubuntu 14.04 comes with apache 2.4 & ubuntu 12.04 comes with apache 2.2.
This new version introduced different default config file names and in general some differences.

So here are the steps to enable mod_rewrite

1. Open terminal (Shortcut ctrl+alt+t).
2. Activate mod_rewrite.

    sudo a2enmod rewrite    

3.  Restart apache.

    service apache2 restart   

4.  To use mod_rewrite from .htaccess file make some changes in virtual host config file.

if you are using ubuntu 12.04 then run

    sudo nano /etc/apache2/sites-available/default

change the line says AllowOverride from None to all. And comment ' Order allow,deny ' line with hashtag(#).

<Directory /var/www/>
       Options Indexes FollowSymLinks MultiViews
       AllowOverride All
       #Order allow,deny
       allow from all
</Directory>

Now if you are using ubuntu 14.04

sudo nano /etc/apache2/sites-available/000-default.conf

And add this line within virtual host config tag.


<Directory /var/www/>
       Options Indexes FollowSymLinks MultiViews
       AllowOverride All
       #Order allow,deny
       allow from all
</Directory>

5.  Restart apache.

    service apache2 restart  

Now you have enabled mod_rewrite successfully. Great job. :)

If you feel this is useful please keep share to your colleagues. Be social.  

 


0 comments: