First, the initial site, the general need to do without WWW domain name 301 to go with the WWW domain name;
The code is as follows:
Options +followsymlinks
Rewriteengine on
Rewritecond%{http_host} ^111cn.net [NC]
Rewriterule ^ (. *) $ http://www.111cn.net/$1 [R=301,NC]
Two, different domain name 301 Jump method;
When you want to change the domain name, we need to move the original weight of the site to the latest site, you need to do a different domain name 301 jump;
The code is as follows:
Options +followsymlinks
Rewriteengine on
Rewritecond%{http_host} ^www.domain1.com [NC]
Rewriterule ^ (. *) $ http://www.domain2.com/$1 [R=301,NC]
Note: This kind of jump, is generally due to the site revision, if you want to maximize weight transfer, please according to Baidu Webmaster platform to solve the solution.
The above 2 methods, for Apache, if you use non-Apache (such as: Nginx), then you can not use the. htaccses file, you can not work with the above methods, then how to do? -- Direct 301 Jump changes to the page!
One, to a single page for 301 jump , just the top of the PHP page to enter the following code can be. The code is as follows:
<?php
Header ("http/1.1 moved Permanently");
Header ("Location:http://www.111cn.net");
?>
Second, for the Total station page 301 Jump Solution
1, the establishment of 301.php files
(File name yourself)
? php
$the _host = $_server[' http_host '];//get the current domain name
$the _url = isset ($_server[' Request_uri '))? $_server[' Request_uri ']: "//To determine the back part of the address
$the _url = strtolower ($the _url);//Turn English letters to lowercase
if ($the _url== "/index.php")//Judge is not the home page
{
$the _url= "";//if the first page, the assignment is null
}
if ($the _host!== ' www.111cn.net ')//If the domain name is not with WWW URL then proceed to the following 301 jump
{
Header (' http/1.1 moved Permanently ');/Send 301 Head
Header (' location:http://www.111cn.net '. $the _url);//jump to Web site with www
}
?>
2, in the Web page file to call 301.php
<?php include ("301.php");? >
Put this code in front of all your pages.
OK, redirect is done, 301 files uploaded to the site directory, you can go to see your results.