Home > How To, Internet, Tutorial > How To Redirect Webpage

How To Redirect Webpage

April 18th, 2009 Leave a comment Go to comments

In this post, I am going to explain one of the two simple ways to redirect a webpage to another webpage.

Client Side Redirect (carried out by your browser)
You can create a webpage that instructs the browser to redirect a webpage to another after certain time delay. The time delay is purely optional.
This is achieved using the meta refresh command which is to be placed within the head tags. Here’s the general syntax :

<head>
<meta http-equiv="refresh" content="N; URL=destination_webpage_address">
</head>

The browser redirects the user from the current page to the destination webpage address specified in the “URL” attribute of the meta tag after a time delay of N seconds.
If you do not want any time delay and want the browser to redirect immediately, you can set the delay time N=0.

What’s the use of time delay option ?
Almost all browsers can successfully handle these automated redirects. Most of the browsers allow the user to turn off this feature to prevent phishing,spam, etc. In such cases, we can provide an message and usual link to the destination address. The browser displays the message and link for specified time and then automatically redirects.
Here’s a complete example of a redirecting webpage. Consider that I save the following code in file named index.html

<html>
<head>
<title>TechnoHolics – Automatic Rediraction Example</title>
<meta http-equiv=”refresh” content=”4; URL=http://www.prashanthpai.com/main.html”>
</head>
<body>
If your browser doesn’t automatically redirect you to the main page after 4 seconds, you will have to <a href=”http://www.prashanthpai.com/main.html”>Click Here</a>.
</body>
</html>

In the above example, whenever a user accesses the webpage http://www.prashanthpai.com/index.html, the browser redirects the user to http://www.prashanthpai.com/main.html after 4 seconds. If the user has disabled automatic redirection in browser, he can click the “Click Here” button to reach the destination webpage.

Aliter :
There’s another method of achieving client side redirect with the use of window.setTimeout in JavaScript. But I prefer the use of meta tag method cause JavaScript may be disabled by the user using Browser’s Options or Firefox NoScript AddOn.

Note :
Server Side Redirect (carried out by the webserver) : This redirect is carried out by the webserver. You will have to just edit the .htaccess file on your server.

  1. November 1st, 2010 at 21:40 | #1

    I would like to propose not to hold back until you get big sum of cash to order all you need! You can take the credit loans or secured loan and feel fine

  1. No trackbacks yet.