Ec (2); 301 redirect code and Method: 301 redirect Header (& quot; HTTP1.1301MovedPermanently & quot;); Header (& quot; Location: www.111cn.net & quot ;);? 301 redirection under ASP & lt; % @ brief agevbscript % & gt script ec (2); script
301 redirection code and Method
301 redirection in PHP
Header ("HTTP/1.1 301 Moved Permanently ");
Header ("Location: http://www.111cn.net ");
?
301 redirection under ASP
<% @ Language = VBScript %>
<%
Response. Status = "301 Moved Permanently"
Response. AddHeader "Location", "http://www.111cn.net"
%>
Redirection of 301 under ASP. NET
301 redirection in ColdFusion
<. Cfheader statuscode = "301" statustext = "Moved permanently">
<. Cfheader name = "Location" value = "http://www.111cn.net">
Old domain name redirected to new domain name
Create a. htaccess file and write the following code into the file. This ensures that all directories or webpages of the old domain name are correctly redirected to the new domain name.
Remember that the. htaccess file must be placed under the root directory of the old website, and the new website must maintain the same directory structure and webpage file with the old website.
Options + FollowSymLinks
RewriteEngine on
RewriteRule (. *) http://www.111cn.net/[R = 301, L]
Change www.111cn.net to the domain name you want to jump.
In addition, I suggest you back up the External links of the old website and contact the corresponding site to modify the URL of the import chain to point to the new site.
4. Use mod_rewrite Technology
The changes made through this technology will be reflected in the. htaccess file, such:
Options + FollowSymLinks
RewriteEngine on
RewriteCond % ^ cfan365.cn
RewriteRule ^ (. *) $ http://www.111cn.net/[R = permanent, L]
5. Bind/local DNS (Domain Name alias jump)
If you have the permission to edit and modify local DNS records, you only need to add a record to solve this problem.
If you do not have this permission, you can ask the website hosting service provider to set the DNS server accordingly.
DNS server settings
To direct aaa.cfan365.cn to www.111cn.net, you only need to add an alias record IN the DNS service, which can be written as aaa in cname www.111cn.net.
If you need to configure a large number of virtual domain names, you can write them as * in cname www.111cn.net.
In this way, all unconfigured records ending with cfan365.cn can be redirected to www.111cn.net.
6. use ASP/PHP to implement 301 redirection:
The Code has been introduced above
Senior SEO expert Dan Thies's views and suggestions
Dan Thies has a deep understanding of the problems encountered by Business.com, because he has had similar experiences. There is a member tracking script on his website. One of the member's sites maps to this tracking script through the 302 command, and the tracking script maps to his home page through 302. When "keyword research" is used in Google for search, his home page ranks in the top 10, but the address shows the Member's website. The results make him laugh: visitors access his website through Google search results, but he has to pay for these visits to the member! The problem is solved only when the robots.txt file is used to prohibit Spiders from tracking and accessing the member tracking script.
For Business.com, Dan Thies believes that there are still some problems with Google's 302 redirection processing, but it does not mean that Google does not allow 302 redirection. Business.com is not blocked or punished. They only return an error response ."
Dan Thies suggests: If the tracking URL/script is used, and the attacker redirects to a specific landing page, it is necessary to prohibit Spiders from accessing the second redirection in the robots.txt file. If no redirection is made to the tracking URL or script, but the external URL is copied, Spiders should be prohibited from accessing the tracking URL in the robots.txt file to prevent repeated content from being punished by the search engine.
301 redirection experience
Experience of a multi-domain website owner:
"I only have one website with the primary domain name www.111cn.net. In addition, there are more than a dozen domain names, such as domain1.com, domain2.com, and domain3.com. All these subdomain names are mapped to www.111cn.net, and all domain names correspond to the same IP address. In fact, I only have one site, and one site can only correspond to one. htaccess file. Obviously, it is impossible to directly modify the. htaccess file to achieve redirection. I used the following steps:
A. Separate domain1.com from cfan365.cn to make it an ordinary independent website on the server.
B. Create a. htaccess text file for domain1.com and set the redirection code:
Redirect permanent/http://www.111cn.net/
Upload the modified. htaccess file to the server where domain1.com is located.
This step can also be completed in the domain name control panel.
Abc directory under the first-level domain name www.111cn.net
Original access address: www.111cn.net/abc
Now I want to add the second-level domain name abc.111cn.net to the directory abc
How can I direct www.111cn.net/abcpermanent to abc.111cn.net?
Server Environment: win2003 + IIS6 + php
Bytes.
Another problem is that after 301 is permanently targeted,
How to pass GET parameters of dynamic pages?
Direct abc/index. php to abc.xxx.com/index.php permanently
If you enter
Abc/index. php? XXXXX = 123
The page is directly forwarded
Abc.xxx.com/index.php
However, the GET parameter xxx = 123 does not exist.
Is it necessary to add code in the header of the dynamic file:
First, judge the client URL. If it is not abc.xxx.com/index.php
Output
Header ("HTTP/1.1 301 Moved Permanently ");
Header ("Location: abc.xxx.com/index.php? GET parameters and values ");
PHP implementation method (reference ):
The. htaccess File Code is as follows (bloghuman.com's. htaccess is set as follows ):
Options + FollowSymlinks
RewriteEngine on
Rewritecond % {http_host} ^ bloghuman.com [nc]
Rewriterule ^ (. *) $ http://www.bloghuman.com/%1%r%301,nc]
Note 1: If the user accesses the ingress.
NOTE 2: Test URL: http://www.wlxs.com.cn/, you can visit http://www.wlxs.com.cn/post/301.htm
I configured the. htaccess file in wlxs.com.cn to redirect its 301 to the http://www.bloghuman.com/post/301.htm
In my. htaccess configuration, the primary domain name (bloghuman.com) 301 is redirected to the second-level domain name (www.bloghuman.com );
Conclusion:
Options + FollowSymlinks
RewriteEngine on
Rewritecond % {http_host} ^ 111cn.net [nc]
Rewriterule ^ (. *) $ http://www.111cn.net/%1%r%301,nc]
How to Implement 301 redirection using an ASP script:
<%
If request. ServerVariables ("HTTP_HOST") = "domain1.com" or request. ServerVariables ("HTTP_HOST") = "111cn.net" then
If Request. ServerVariables ("QUERY_STRING") <> "" then p = "? "
Response. Status = "301 Moved Permanently"
Response. AddHeader "Location", "http://www.111cn.net" & Request. ServerVariables ("SCRIPT_NAME") & p & Request. ServerVariables ("QUERY_STRING ")
Response. End
End if