301 redirect settings

Source: Internet
Author: User
Many people register multiple domain names for a website. For example, I have registered two domain names www.linkhelper.cn and www.adminlj.com for my linked helper network. Many people may be used to binding all their domain names to one site. In fact, this is very unfavorable for websites, because the search engine will not be clear about which domain name you want to promote. As a result, the search engine will kill one of the domain names and keep only one domain name. What's worse, the two domain names are not included in the search engine. Therefore, we need to guide the search engine and tell the search engine which domain name is the primary domain name corresponding to your website. Therefore, it is necessary to set 301 redirection for secondary domain names.

In many cases, two URLs with or without WWW are sometimes processed by the search engine as two domain names. Next, on the premise of IIS Web service, I will explain how to set 301 redirection.

I know that there are two common 301 redirect settings. One is directly set through the IIS interface, and the other is throughCode301 redirection settings. The following example shows how to redirect www.adminlj.com 301 to www.linkhelper.cn.

The first method is to achieve 301 redirection through the IIS interface:

1. Add a website to bind the following Host Header: adminlj.com www.adminlj.com linkhelper.cn. Note that adminlj.com and linkhelper.cn here are different URLs because they do not contain www or www. Corresponding directory e: \ webroot \ 301web. The directory contains only two files, one default.htm and the other 404.htm. As follows:

 

2. in IIS, select the site we just created, right-click, properties, Home Directory, select redirect to, enter the URL: http://www.linkhelper.cn, and pay attention to the permanent redirection of the selected resources below. As follows:

 

3. At this point, we have completed redirecting 301 of the linkhelper.cn www.adminlj.com domain names to www.linkhelper.cn. However, we may have previously publicized domain names without WWW, so that the search engine has included some URLs under linkhelper.cn, we need to transfer the traffic from the search engine to www.linkhelper.cn. So how can we do this. It can be achieved through 404 + 301. Then we set 404 information for this site. Or the IIS interface, right-click, property, custom error, find 404, double-click, and a page is displayed. Then, select the URL in the message type, and enter/404.html in the URL input box below. Then we re-launch the 404.html 301 redirection to the http://www.linkhelper.cn in iis. The procedure is the same as step 1. In this case.

After completing the preceding steps, we have completed the 301 redirect settings in IIS. However, in most cases, webmasters use virtual hosts. In this way, 301 redirection cannot be set through IIS.

Then we can use the second method: through code. The procedure is as follows.

1. Add the website directory and bind the domain name adminlj.com www.adminlj.com linkhelper.cn to the first step of setting the method in IIS. Add default. asp and ensure that default. asp is the first default document.

2. modify the code in default. asp. Code:
<%
Response. Status = "301 moved permanently"
Response. addheader "location ","*****"
%>

In this way, ASP is used to implement 301 redirection.

Reference: Old Beijing farmhouse (http://www.bj1568.com /)
Hong Shi Internet (http://www.hungstone.cn /)

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.