Redirecting codes

Redirecting PHP pages

Redirecting a visitor or the browser is necessary in different situations. If a page is temporarily down at that time we can use HTTP 302 redirect. Same way the permanent redirection is HTTP 301 redirection. Each the 3xx are different types of redirection and out of them 301 and 302 are common. The HTTP 301 permanent redirection is accepted by search engines also.

We will be use the Location Header function to redirect a page. This script works when we have not send to any php or html command to out put any thing in the browser. Trouble is to be taken not to send any other to the browser after the header redirection using location command. Here is the code.

header (“Location: http://www.websitename.com”);

/* Redirect browser to websitename.com web site */
exit; // Closes further script execution .

You can see this code above will redirect the page to a new URL.

Tags:

Request a Free SEO Quote