Enabling mod_rewrite for Apache

Posted: 01/11/2009 in 1

Enabling mod_rewrite for Apache, mod_rewrite is compiled in by default and stoted in the /etc/apache2/mods_available directory as rewrite.load. Following line is added in rewrite.load to enabling the module for Apache.

LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

To enable mod_rewrite follow the commands below.

cd /etc/apache2
sudo cp mods-available/rewrite.load mods-enabled/

sudo gedit sites-enabled/000-default

Find the following line of code snippets

<VirtualHost *:80>
ServerAdmin webmaster@localhost
…..
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride none
Order allow,deny
allow from all
</Directory>
….

</VirtualHost>

Change above code snippets as below

<VirtualHost *:80>
ServerAdmin webmaster@localhost
…..
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
….

</VirtualHost>

Now restart apache server using below commands
sudo /etc/init.d/apache2 restart

Now mod_rewrite is enabled in ur Apache server which allows you to rewrite and manipulate URLs which are sent to your webserver.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s