Redirects in websites serve many purposes. Often, the main purpose is to provide a memorable URL for marketing purposes. For example it is easy for someone to remember www.mysite.com/bingo than www.mysite.com/abc/def/ewrt.html
There are many ways to create redirects.
1. HTML redirects. Use META tag such as
<META HTTP-EQUIV=”refresh”
CONTENT=”10;URL=http://www.mysite.com”>
The above page will redirect after 10 seconds, specified in the content attribute.
Though this works, I am not in favor of using HTML redirects. The reason being HTML redirects are treated as hacks by Search Engines and ignored.
2. Javascript redirects
<html>
<head>
<script type=”text/javascript”>
<!–
function redir(){
window.location = “redirect.html”
}
//–>
</script>
</head>
<body onLoad=”setTimeout(’redir()’, 5000)”>
<h2 >Page is about to be redirected!</h2>
</body>
</html>
Effectively you are using window.location to point the browser to new location. Same as HTML redirects, Search Engines do not like Javascript redirects.
3. Best way in my opinion to set redirects is using 301 redirects. You can set 301 redirects in multiple ways depending on choice of your web scripting language, web server.
For example in JSP (Java)
<%
response.setStatus(301);
response.setHeader( “Location”, “http://www.mysite.com/bingo” );
response.setHeader( “Connection”, “close” );
%>
Using ASP.NET to create redirect
<script runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(”Location”,”http://www.mysite.com/bingo“);
}
</script>
Using IIS to create redirect
In internet services manager, right click on the file or folder you wish to redirect.
Select the radio titled “a redirection to a URL”.
Enter the page that the page will be redirected to.
Check “The exact url entered above” and the “A permanent redirection for this resource”. Click on ‘Apply’
Using Apache to create redirect
In .htaccess file create entries such as
Redirect /ap.html http://mysite.com/ap/ [or]
Redirect /test.html http://mysite.com/bingo/test.html