How to enable mod rewrite in apache server?


What is mod rewrite?

Mod rewrite is an apache module that lets you to rewrite url to another. You can redirect one url pattern to another using regular expression mod rewrite. You can set 404 error document when page is not found. You can also set several other features like hiding your php extensions etc. It lets you to create clean urls instead of having query strings ?type=user&name=john to user/john which is search engine and human friendly.

To use this feature you must have mod_rewrite module enabled in your server. If you dont have it enabled you can do this in this way

 

 

Enable mod rewrite in windows

Simply go to Apache installation folder. Then open conf/httpd.conf with notepad and find the line

#LoadModule rewrite_module modules/mod_rewrite.so

Now uncomment the line by removing the ‘#’ from the front of this line.

LoadModule rewrite_module modules/mod_rewrite.so

Restart Apache Server. From now on mod rewrite will be active.

 

 

 

Enable mod rewrite in ubuntu or linux

Enabling mod rewrite in ubuntu is as easy as entering a command of a2enmod. This command is used to enable apache modules on linux.

Go to terminal enter the following command

sudo a2enmod rewrite

 

This will enable mod rewrite and show the following output in terminal

burhan@burhan-desktop:~$ sudo a2enmod rewrite
Enabling module rewrite.
Run '/etc/init.d/apache2 restart' to activate new configuration!

 

Now you need to restart apache server to get mod rewrite working right from now

burhan@burhan-desktop:~$ /etc/init.d/apache2 restart
 * Restarting web server apache2

 

Hope you will find this useful

No related posts.

Tags: , ,

To make money we lose our health, and then to restore our health we lose our money.... We live as if we are never going to die, and we die as if we never lived!

Leave a Reply