Sometimes we rename files for various reasons. For example, if you were to move your website to a new domain or create a new or temporary version of your page. I often need to do this so that clients using bookmarks will be able to find the page they are looking for after I reorganize the website.

Whatever your reason it, it is recommended. One of my top business principles is, never make it harder for your clients to do business with you if you can avoid it.

There are two main ways I accomplish this. Which method I use will depend on my needs.

HTML

If all you have to work with is HTML, add the following line in the HEAD section of your file:

<meta http-equiv="Refresh" content="0; url=http://www.example.com/" />

Replace www.example.com with the address of your website.

The disadvantage of this method is that it still requires your page to load in to the web browser. If your visitor was to click the back button after having been redirected, they would end up back at the redirection page and just be redirected back. Confused? What all this means is that the back button would essentially be disabled. So what's the alternative?

PHP

If you have access to PHP, you can enter the following code in your file:

<?php
header( "HTTP/1.1 301 Moved Permanently" );
header( "Status: 301 Moved Permanently" );
header( "Location: http://www.example.com/" );
exit(0);
?>

The last line is optional but suggested in order to avoid any accidental output. It is important to note that this will not work if any text at all has been sent to the web browser before these lines. If that's the case, you will have to use HTML example above instead.

TIP: It is a good idea to add additional HTML which will appear on the page in the event that the redirection doesn't happen. For example:

Click <a href="http://www.example.com/">this link</a> if you are not automatically redirected.

Using a different language? Check out this article on How to Redirect a Web Page. (archived from Wayback Machine)