Mywebdunia's Blog

Posts Tagged ‘redirecting url

Well most of us are aware of getting redirected to some other page say when downloading something. Most of these sites achieve this using a script that processes the state change and then redirects to the page that they want the user to see.

There are some ways to achieve this:

1. Using Meta Tag : Redirection can be achieved by using the meta tag. Below is an example how to achieve this.

Ex: <meta http-equiv=”Refresh” content=”5;URL= new-url.html” />

Put the above code within your head tag. It’s very easy and simple, this will redirect to the above page after displaying the current page for five seconds.

2. Using HTTP Header Location : This method is a php method to redirect the url to new location.

Ex:
<?php
header(“Location: new_url.php”);
?>

This uses the header function to redirect, the header function send the raw HTTP headers to the browser’s. So you need to do this before sending any other output to the browser.

There are two advantages of HTTP header location 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.

But in the first method using meta tag. 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. Also, page refresh in meta tags may be considered spam by search engines like google and yahoo.


Categories