301 Represents a permanent transfer (permanently Moved),
301 Redirection is the best way to search engine friendly after changing the address of a webpage, as long as it is not temporarily moved, it is recommended to use 301来 to do the forwarding address.
ABC.com Redirect to www.abc.com. PHP code can be written like this:
<?php$the_host = $_server[' http_host '];//get current domain name $the_url = isset ($_server[' Request_uri ')? $_server[' Request_uri ': ';//Determine the address after the $the_url = Strtolower ($the _url);//Convert the English letter to lowercase if ($the _url== "/index.php")// Judge is not home { $the _url= "";//If it is the first page, assignment is empty}if ($the _host!== ' www.icoa.cn ')//If the domain name is not a URL with www then proceed to the following 301 jump { header (' http/1.1 301 Moved permanently ');//Issue 301 Header Header (' location:http://www.icoa.cn '. $the _url);//jump to URL with www }? >
This article turns from http://www.icoa.cn/a/475.html
PHP with 301 permanent Redirect Domain name