Set 301 redirect (all)

Source: Internet
Author: User

When multiple domain names direct to your site,301 jumpIt is a common page Jump method for each website. For Seo, it has the following functions:

1,301 jump is a jump method recognized by the search engine. That is to say, jumping from a web site to another web site is not punished by the search engine.

2. As mentioned above, this jump method is recognized by search engines. Search Engine designers and considering that a domain name may not always follow a website for a lifetime, with this redirection method, the search engine determines that you "permanently" discard the domain name and enable a new domain name. Then, the search engine will transfer the weight of your old domain name to the new domain name. However, it should be noted that the weight can not be completely transferred through the 301 jump, which is determined by many factors. 301 can only be said to minimize the loss.

301 specific settings

1,IISSettings in Section 301

Internet Information Service Manager-> virtual directory-> redirect to URL, enter the target URL to be redirected, and select "permanent resource redirection ".

2,ASPLower 301 redirectionCode

<% @ Language = VBScript %>
<%
If request. servervariables ("SERVER_NAME") = "fanhefan-blog.tk" then
Response. Status = "301 moved permanently"
Response. addhead" location "," www. fanhefan-blog.tk"
Response. End
End if
%>

3,ASP. NETNext 301 turn to code

<SCRIPT runat = "server">
Private void page_load (Object sender, system. eventargs E)
{
Response. Status = "301 moved permanently ";
Response. addheader ("location", "www. fanhefan-blog.tk/301/");
}
</SCRIPT>

4,PHPNext 301 turn to code

If ($ http_server_vars ["http_host"] = "fanhefan-blog.tk)

{
Header ("HTTP/1.1 301 moved permanently ");
Header ("Location: www. fanhefan-blog.tk ");
}

5,Cgi PerlNext 301 turn to code

$ Q = new CGI;
Print $ q-> redirect ("www. fanhefan-blog.tk/301 /");

6. 301 redirection code under JSP

<%
Response. setstatus (301 );
Response. setheader ("location", "www. fanhefan-blog.tk/301 /);
Response. setheader ("connection", "close ");
%>

7,ApacheNext 301 turn to code

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 ^ (. *) $ www. fanhefan-blog.tk/301/[L, r = 301]

2) redirect to a new domain name

Options + followsymlinks
Rewriteengine on
Rewriterule ^ (. *) $ www. fanhefan-blog.tk/301/[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>
ServernameWww. fanhefan-blog.tk

DocumentRoot/home/seotest
</Virtualhost>

<Virtualhost *: 80>
Servername seotest.com
Redirectmatch permanent ^/(. *) www. fanhefan-blog.tk/301/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.