301 redirects can transfer multiple domain weights to specific domain names to enhance the unique allocation of domain name weights. On the other hand, after the domain name is replaced, use 301 redirect to the old domain name weight, redirect to the new domain name above. This 301 redirect has been widely used. Especially in the construction of the site will often appear in the "Level two domain name, level three domain name, top-level domain name" directed to the specified with three "W" level two domain name. However, due to the different program language, server operating system, Web site operating environment and other factors, resulting in "301 directional diversity of confusion." In the actual operation is often because of multiple problems, can not correct the site to be directed. Today will be a comprehensive written in different environments, the site how to do 301 REDIRECT Experience summary analysis:
One: Linux system's Virtual host
Use Notepad to build a document that reads:
Rewriteengine on
Rewritecond%{http_host} ^*****.com [NC]
Rewriterule ^ (. *) $ http://www.*****.com/$1 [l,r=301]
Then save the file name: ". htaccess", if the virtual host support, then 301 redirect will be correctly implemented. For program: Unlimited!
Second: The virtual Host in NT system
Compared to the NT system to do 301 redirects, the requirements are more stringent than the Linux system, but relatively speaking there are many ways:
1, iis7.0 The following system, ASP language:
<%@ Language=vbscript%>
<%
Response.status= "Moved Permanently" Response.AddHeader "Location", "http://www.****.com"
%>
You can add content to the head of the page you want to redirect, and 301 can be added to such common documents as top.asp, conn.asp, etc.
2, IIS7.0 System, PHP language:
Header ("http/1.1 moved Permanently");
Header ("location:http://www.domain.com");
?>
Note: HTML page can not add 301 redirect code, only support JS jump or meta REFRESH, and for HTML jump, more often show results for "302" temporary orientation, easy to be considered as cheating by search engines.
3, IIS7.0 above operating system
A "Web.config" file can be created with the directory, followed by a 301 redirect:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name= "WWW Redirect" stopprocessing= "true" >
<match url= ". *"/>
<conditions>
<add input= "{http_host}" pattern= "^***.****.com$"/>
</conditions>
<action type= "Redirect" Url= "http://www.*****.com/{r:0}"
Redirecttype= "Permanent"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Three: System-insensitive 301 redirects
Do not differentiate the operating system's 301 redirects, first build a "subdirectory" named "301", and then use TXT notepad to create a file:
<%@ language=vbscript%>
<%response.status= "Moved Permanently"
Response.AddHeader "Location", "www.*****.com"
%>
Finally save the file name as "Index.asp", of course, you need the virtual host to support the default document for the home page. After that will need to do a turn to the domain name such as: "admin5.com" binding to the subdirectory "301". Next, in a refresh, see if you have done 301 redirect it? But without depth testing, I do not know whether it is not conducive to optimization. The binary was observed for a few days and no exceptions were found.
This article only on the virtual host of the 301 redirect to do a more explanation, I hope that the majority of the use of virtual host to help the webmaster. And for stand-alone servers or VPS webmaster, can be defined by the server settings to define 301, this also does not do too much description. Virtual host settings 301 different environments require different treatment, and setting errors can easily lead to unpredictable results. At the same time set up, the binary network with Shanghai Network Company Pilotage Technology (www.joyweb.net.cn) more recommended by the majority of webmaster use "301 Redirect Detection Tool" To do a test, if the return code for "301" is directed success, and once returned 302, it needs to be taken seriously. However, using code like this does not return 302, and more often, the 302 temporary orientation that is returned after the jump is used in a static page.