Redirect URLs using .htaccess

The feature is very useful if you have recently redesigned your site but you wish to keep the old addresses working for various reasons (you have links to these pages from other sites, some users may have the old pages bookmarked, etc).
The Apache web server provides several way for setting up redirects.

The most simple one is using the “Redirect” directive:

Redirect /folder http://www.example.com/newfolder

Another useful directive is the RedirectMatch. With it you can use regular expressions in the redirect condition. For example

RedirectMatch “\.html$” http://www.example.com/index.php

This will redirect all requests to files that end with .html to the index.php file.

Posted by Mahesh ( Tryangled )

Leave a Reply

You must be logged in to post a comment.