By Ajay, Category: SEO, Date: January 16, 2008

mod_rewrite is one of the most famous URL manipulating module available in Apache web server.

One of the most common drawbacks of a language like PHP is its inability to generate SEO friendly URLs.

mod_rewrite is very useful for SEO and certainly required for any dynamic website in order to achieve Google Top 10 ranking.

Lets take an example.

The existing URL for a product on SwamiPC

could have been something

without mod_rewrite.

mod_rewrite modules gives flexibility to rewrite the URLs on fly.

It provides unlimited number of rewrite rules and not only that it also provide flexibility to implement mod_rewrite on directory/subdirectory (.htaccess) level or domain level (httpd.conf).

The most common method to implement mod_rewrite rule is in .htaccess as httpd.conf will normally not available to end users.

.htaccess also offers you to rewrite URLs in directory level.

mod_rewrite directives

Following are the most common mod_rewrite directives


Syntax: RewriteEngine on|off

This directive is used to switch mod_rewrite engine on or off


Syntax: RewriteOptions option

This directive is used to set some special options.


RewriteOptions MaxRedirects 19


Syntax: RewriteLog filepath

This directive is used to specify the log file for capturing mod_rewrite logs which comes handyduring debugging.


RewriteLog “/var/home/user/ajay/logs/rewritelog.log”


Syntax: RewriteRule pattern substitution

This is the most important directive which we look for. This directive is used to define rewrite rule.

It is defined per rule and can be used as many times as required.

pattern is a POSIX regular expression


Leave a Reply