The Apache web server has a module called mod_rewrite which allows a URL in the client’s browser to redirect to another URL, all by manipulation on the server side and without any change in the client’s submitted URL.
mod_rewrite helps to create “clean URLs” and this module is commonly used by many CMS and blogging platforms like WordPress and Drupal.
To check if mod_rewrite has been enabled or not, just create an empty (xyz).php file anywhere on your web root and write the following line:
Open this file in any web browser using http://domain/xyz.php and check out apache2handler. mod_rewrite would appear there if it is enabled.
Consider a website which takes input in the form http://abc.com/name.php?q=sachin. This looks ugly and is not search engine friendly. We would like to have something like http://abc.com/name/sachin. This would be nice and easy to remember. For this let us create a rule for mod_rewrite.
RewriteEngine On
RewriteRule ^name/(\w+)/?$ name.php?id=$1
The Rewrite engine is going to examine the incoming URL requests and convert the friendly URL into the URL understandable by the server!!
]]>