HOTScripts.comRedirecting a visitor or the browser is required for a variety of reasons. If a a page is temporarily down you can use a HTTP 302 redirect. Same way permanent redirection is HTTP 301 redirection. All the 3xx are different types of redirection and out of them 301 and 302 are the most common. HTTP 301 permanent redirection is well accepted by search engines also. We will discuss the PHP redirection method here.
Using Location Header function to redirect a page.
This script works when we have not sent any php or html command to out put any thing in
the browser. Care should be taken not to send anything to the browser after the header
redirection using location command.
You can see the above code will redirect the page to a new URL.
Now, let's write the code for 301 redirection (page permanently moved )
It comes in handy to know how to redirect one page to another page. PHP makes it easy! This tiny piece of code shows the syntax that causes the visitor to redirect to a different URL than the one they 'landed' on. The following php script redirects the user to /index.php within the same site:
The redirection target can be any suitable URL as could be used in the href parameter of an address tag (such as http://www.adinstall.com/index.php).
The header function sends raw header data to the client web browser and in this case sends a 302 status code which instructs the browser to redirect to the given location.