XI sishu switched the 301 required in Seo workCodeSorted, added to favorites, and shared for reference.
1. Set IIS 301
Internet Information Service Manager-> virtual directory-> redirect to URL, enter the target URL to be redirected, and select "permanent resource redirection ".
2. Code redirection in ASP 301
<% @ Language = VBScript %>
<%
Response. Status = "301 moved permanently"
Response. addheader "location", "http://www.lesishu.cn/articles/301"
%>
3. 301 redirection code under ASP. NET
<SCRIPT runat = "server">
Private void page_load (Object sender, system. eventargs E)
{
Response. Status = "301 moved permanently ";
Response. addheader ("location", "http://www.lesishu.cn/articles/301/");
}
</SCRIPT>
4. php 301 redirection code
Header ("HTTP/1.1 301 moved permanently ");
Header ("Location: http://www.lesishu.cn/articles/301 ");
Exit ();
5. The 301 redirection code in cgi Perl
$ Q = new CGI;
Print $ q-> redirect ("http://www.new-url.com /");
6. 301 redirection code under JSP
<%
Response. setstatus (301 );
Response. setheader ("location", "http://www.lesishu.cn /");
Response. setheader ("connection", "close ");
%>
7. Switch to code 301 in Apache
Create a new. htaccess file and enter the following content (mod_rewrite must be enabled ):
1) switch the domain name without WWW to the domain name with WWW
Options + followsymlinks
Rewriteengine on
Rewritecond % {http_host} ^ lesishu.cn [Nc]
Rewriterule ^ (. *) $ http://www.lesishu.cn/#1 [L, r = 301]
2) redirect to a new domain name
Options + followsymlinks
Rewriteengine on
Rewriterule ^ (. *) $ http://www.lesishu.cn/#1 [L, r = 301]
3) use regular expressions for 301 redirection to achieve pseudo-static
Options + followsymlinks
Rewriteengine on
Rewriterule ^ news-(. +) \. html $ news. php? Id = $1
Add news. php? Ids0123the address is directed to news-123.html.
8. Configure 301 redirection in vhosts. conf under Apache
To achieve URL standardization, Seo usually redirects a domain name without WWW to a domain name with www. The configuration in vhosts. conf is as follows:
<Virtualhost *: 80>
Servername www.lesishu.cn
DocumentRoot/home/lesishu
</Virtualhost>
<Virtualhost *: 80>
Servername lesishu.cn
Redirectmatch permanent ^/(. *) http://www.lesishu.cn/#1
</Virtualhost>
In addition to the preceding two methods in Apache, there are other configuration methods and optional parameters. We recommend that you read the Apache documentation.
301 steering Condition Detection
- Http://www.seoconsultants.com/tools/headers.asp
- Http://www.internetofficer.com/seo-tool/redirect-check/
Author: Yan sishu
Original: dianshi interactive search engine optimization blog