REDIRECTING

 

One of the most common uses for .htaccess, not counting custom error pages, is to use it for redirecting. By using .htaccess you can redirect a users request to a whole other file, or even better, a whole other website, and all instantly. Lets take a look at the command we use to accomplish this:

Redirect /folder/sub_folder/page.php http://www.somesite.com/folder/page.php

In the above example, every time a user sends a request to the server asking to access the file page.php, which is stored in folder/sub_folder, the server will reply with the url to the new website (www.somesite.com in this case). This all happens within milliseconds, so the user doesn't notice anything except for a different address in his address bar.

You can also redirect whole directoires of your site using the .htaccess file, for example if you had a directory called olddirectory on your site and you had set up the same files on a new site at: http://www.newsite.com/newdirectory/ you could redirect all the files in that directory without having to specify each one:

Redirect /olddirectory http://www.somesitecom/newdirectory

Then, any request to your site below /olddirectory will bee redirected to the new site, with the extra information in the URL added on, for example if someone typed in:

http://www.somesite.com/olddirecotry/oldfiles/images/image.gif

They would be redirected to:

http://www.somesite.com/newdirectory/oldfiles/images/image.gif

 

Hosted by www.Geocities.ws

1