1. If you are looking for redirecting to a page using JavaScript then check the following code
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
function redirect()
{
window.location = "http://www.google.com"; //specify the destination page here.
}
</script>
</head>
<body onload="setTimeout('redirect()',5000);">
You will be redirected to the main page in a moment...............
</body>
</html>
I've used setTimeout() just to give a delay before the redirection.
2. Using the META tag of HTML you can perform the redirection. Refer the following code
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Redirecting using META tag</title>
<meta http-equiv="refresh" content="5;URL=http://www.google.com" />
</head>
<body>
You will be redirected to the main page in a moment...............
</body>
</html>
3. Using a 301 redirect (using .htaccess file)
How to implement the 301 Redirect
Hope your webserver supports .htaccess file if then you've created/editing the same in the following manner
1. Place this code in your .htaccess file:
redirect 301 /oldsite/oldpage.html http://www.you.com/new.htm
2. If the .htaccess file already has lines of code in it, skip a line, then add the above code.
5. Save the .htaccess file
6. Upload this file to the root folder of your server.
7. Test it by typing in the old address to the page you've changed. You should be immediately taken to the new location.
4. Using server-side scripting tools like ASP or PHP you can redirect to new locations also.
Bookmarks