Reasons To Redirect Or Forward A URL
There are different reasons to redirect a URL.
You may have moved your website to a different server or you want your visitors to always be redirected to a different URL.
Ways To Redirect A URL
1) Update the DNS database. (Most web hosts will have a control panel where you can do this).
a) Set the TTL in the DNS database to 20 minutes at least 24 hours before you move your site.
b) Copy your files to your new server.
c) Check that your site is working properly by updating your hosts file and visiting the site in your browser in the normal way:
Previewing Your Domain Pre-Transfer
d) Change the IP address in the DNS database.
2) Use a .htaccess file
If you're using a webserver that supports .htaccess files such as apache you can redirect visitors by creating a file in a text editor and adding this content:
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
3) Use The Meta Tag Refresh
If you create or modifiy a webpage with the following content your pages will be redirected
<head>
<title>Page Title</title>
<META http-equiv="refresh" content="5;URL=http://www.newdomain.com/a-special-directory/another-directory">
</head>
4) HTTP Headers Using A Scripting Language
Server-side scripting languages for the web have methods of outputting HTTP Headers.
The first thing your webserver must see is the header information otherwise you'll generate a 500 Internal Server Error.
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.newdomain.com/');
exit();
You'll need to check the documentation of your scripting language for the exact syntax.
5) HTTP Refresh Header
header('Refresh: 0; url=http://www.newdomain.com/');
print('Content-type: text/html');
print('Please visit our new site at <a href="http://www.newdomain.com/">www.newdomain.com</a>.');
exit();
6) Frame Redirect
You can use HTML Frames to display another site:
<frameset rows="100%">
<frame src="http://www.newdomain.com/">
<noframes>
<body>Please follow <a href="http://www.newdomain.com/">link</a>.</body>
</noframes>
</frameset>
You can also use Inline Frames:
<iframe height="100%" width="100%" src="http://www.newdomain.com/">
Please follow <a href="http://www.newdomain.com/">link</a>.
</iframe>
7) Manual Redirect
You can simply place a link on a webpage directing visitors to another URL:
Please visit our new site at <a href="http://www.newdomain.com/">www.newdomain.com</a>.