You may want redirect one website to another for some reason. This article show you how to redirect a website to another using php scrips. When you do it should be more search engine friendly at any cost.
PHP Redirect Code
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://www.tutsplanet.com");
exit;
Basically you can avoid the first line, but this would result in “302 Moved Temporarily” redirect instead of 301. But keep this in mind 301 redirects are more search engine friendly.
You can redirect to inner pages also as shown below:
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.tutsplanet/article.php");
exit;
Why I used exit in here, after the redirect header function we should not print anything, even a white space will cause stopping the redirection and showing an error.
- Just want to thank us? Buy us a Coffee
- May be another day? Shop on Amazon using our links.
Your prices won't change but we get a small commission.
Leave a Reply