Home Internet Marketing Search Engines Tech Talks Web Design Contact

Little bit about Mod_Rewrite

Filed under: Tech Talks |

Mod_Rewrite is a rewrite engine or web server software of Apache HTTP server and is used for rewriting web page url at the server level giving the final output to the user. This rewrite engine is mainly used for making the web page url more user and search engine friendly.

If you provide users with meaningful urls that really describes the content of that page, then it will be easier for them to keep in mind. Moreover search engines also find it easy to index pages whose urls have been rewritten using mod-rewrite.

To run the mod-rewrite, you should have the mod_rewrite module installed on your Apache server. To check whether you have mod_rewrite installed, you need to create a file named phpinfo.php, write and save it on your server. Then search for “mod_rewrite” and you will find it in the “Apache loaded section”. If you miss that, you can ask for it to your hosting company.

The Mod_rewrite rule is written in .htaccess file. The .htaccess (hypertext access) file is a text file which contains Apache directives. Any directives that you use will be applicable to the directory where .htaccess files resides and all the sub-directory under it.

The structure of rewrite rule

RewriteRule Pattern Substitution [OptionalFlags]

Where,

RewriteRule is just the name of the command. Pattern is a regular expression, which will be applied to the current url. Any back references or server variable names can be used in substitution. OptionalFlags are the only mandatory part in the RewriteRule. The flags should be written within square brackets and separated by comma. You can find full list of flags in the Apache mod_rewrite manual.

Technorati Tags: , , ,

Share this post:

Bookmark with Delicious   Bookmark with Digg   Bookmark with Technorati   Bookmark with Stumbleupon

3 Comments»

  1. Comment by rhituparna ganguly — September 4, 2007 @ 5:08 am

    Hi!
    Its an informative post indeed…being a completely non tech person the entire thing is new for me.I value your information and expect more new posts to to come up in the same standard

  2. Comment by Bloggergurl — September 10, 2007 @ 7:46 am

    True!
    This feature would help us to keep a lot of url confusions at bay!
    Yes, at the same time you would also make it easier for the search engines bots to crawl in relation to your content which in turn would definitely help improve your PR!
    Thanks for this gift,
    Bloggergurl

  3. Comment by Anirudh — September 11, 2007 @ 3:12 am

    Interesting article, and making a user and SE friendly URL is very important.

    lot of things can be done through .htaccess and I hope to read lot more on the same in this blog….Great Going Mitra Sir ;)

RSS feed for comments on this post. - TrackBack URL

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>