There are essentially two ways to do it:
First Method: (preferred and best way)
This method uses the HTTP Location header, like this:
QUOTE
<?
header("Location: new_page.php");
?>
The header() function sends raw HTTP headers to the user's browser. Therefore, you need to do this before sending any other output to the browser, just as you would when setting a cookie. There are two advantages to this method. First, it is instant, and the intermediate script does not appear in a web browser's history. Second, because it is HTTP based, it does not require a web browser to process; automatic web crawlers and programs such as wget understand it.header("Location: new_page.php");
?>
Second Method:
However, if you would like to show an intermediate page to the user with a delay, you need to use a different method that uses the HTML <meta> tag. It's pretty simple; to send a user to a different page after displaying the current page for five seconds, put the following in your HTML header:
QUOTE
<meta http-equiv="Refresh" content="5;URL= new_page.php" />
All web browsers understand this, but automatic page crawlers sometimes do not. In addition, this intermediate page will show up in the user's browser history. Beware, page refresh in meta tags may be considered spam by search kings like google and yahoo.
Redirection's use when shifting domains:
Ok, so you were using a free subdomain like .co.nr or others. You have developed your site well, attracted some good traffic, and even probably earned some money through advertisements. You are now thinking to buy a cool .com domain. Yes! you even masked your .co.nr address to just show the same link in every page so that when you change domain your old links just dont throw page not found error on visitors face. But wait! What about the traffic which you would be recieving on the old address. If you were using a .co.nr address you had to show thier ad link on the first page, but you have your own domain right? So, the first idea of directly updating your .co.nr address to the new domain is not nice at all.
So you already know that you can use a page in between containing "This site is being redirected to new address" and redirect after five seconds. But .co.nr people are smart and wont allow you to do this neither direct redirecting using php method. In addition to bots they manually check the users subdomains. So what you can do???
Simple. Just create an exact replica of your main index page and add the ad link which they want you to show. Change every link on that page with thier respective address in your new domain. Now link this page to your old .co.nr address. That's it. Now your visitors coming from new domain won't be seeing any .co.nr ad link. And in the process also taking care of the visitors from the old address. Also you can host this page on your current host and can even add a statistic logging code to this page to see how many people from which place are still coming through your old address.
These things would not have been possible if you directly linked to your new address. Was it? I have seen majority (even myself) of people using .co.nr domains and this may be the only method you would use for this major change.


