Redirect to a Different URL using .htaccess
Posted: February 26th, 2009 | Author: Henrie Media Inc. | Filed under: Code Library, Configuration | No Comments »
You can use .htaccess to redirect users to a different URL. The .htaccess looks for any request for a specific page and if it finds that request, it forwards it to a new page you have specified.
The syntax is:
redirect accessed-file URL-to-go-to
There are 3 parts;
(1) the Redirect command,
(2) the location of the file/directory you want redirected, and
(3) the full URL of the location you want that request sent to.
These parts are separated by a single space and should be on one line.
For example, if you want to redirect users from oldfile.html in the www directory of your account, myaccount, to newpage.html, the syntax should be
redirect /oldfile.html http://www.carefreetrip.com/newpage.html
Anyone going to http://www.carefreetrip.com/oldfile.html will end up on http://www.carefreetrip.com/newpage.html.
You must use a full URL even if you’re going to send the users to another page on your own site.
You can also redirect an entire directory:
redirect /old_dir/ http://www.carefreetrip.com/new_dir/
Anyone going to http://www.carefreetrip.com/old_dir/filename.html will end up on http://www.carefreetrip.com/new_dir/filename.html.
After you set up the redirect, you should test it by going to the old URL.






Leave a Reply