Little bit about Mod_Rewrite
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: mod rewrite, .htaccess, arindam,
























3 Comments»
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
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
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