301 permanent redirect is a way to redirect from one webpage to another that is most efficient method and search engine friendly way for redirecting your website. you can perform the redirecting for some reason such like.
1. redirect an old website to a new address .
2. redirect to omit (www. ) or include (www. ).
3. setup several domains pointing.
4. beauty a URL structure change.
The basic example of the script such like single page redirect.
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.newdomain.com/page.html");
exit();
?>
Include www. redirect
<?php
if (substr($_SERVER['HTTP_HOST'],0,3) != 'www')
{
header('HTTP/1.1 301 Moved Permanently');
header('Location: <a href="http://www.">http://www.'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'</a>]);
}?>
It is fun and interesting tips for your redirect webpages process.
No comments:
Post a Comment