301 redirection rule settings and WWW weight issues

Source: Internet
Author: User

When we open the website, most of them are used to adding WWW in front, for example: www.qqzer.com. Few people do not add www. In fact, this is two different domain names, and WWW is a second-level domain name, WWW is a top-level domain name. They can bind and direct to different spaces, but in implementation, both domain names open the same website.
When we use site: www.qqzer.com and site: qqzer.com on Baidu or Google, you will find the difference between them. If the site is not added with WWW, the number of entries will be more than that added with www, if you do not add WWW, all the documents of the second-level domain name will be displayed. That is, the weight of the second-level domain name without WWW is higher than that of WWW.
If the same website uses both the second-level domain name and top-level domain name, but the weights are relatively scattered, we need to use 301 redirection.
According to user habits, we use the second-level domain name added with WWW as the primary domain name, while the top-level domain name performs 301 redirection and points to the domain name added with www. The 301 targeting method is as follows:
I know that there are two common 301 redirect settings. One is directly set through the IIS interface, and the other is to implement 301 redirect settings through code. The following example illustrates how to redirect to nxmyhome.com 301.

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

1. Add a website to bind the following Host Header: nxmyhome.com. Note that the qqzer.com is used as a different URL by the search engine without 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.qqzer.com, and pay attention to the permanent redirection of the selected resources below. As follows:

  

3. At this point, we have completed redirecting the qqzer.com domain names 301. However, in general, we may have previously publicized domain names without WWW, so that the search engine has included some URLs under qqzer.com, we need to transfer the traffic from the search engine. 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 try again on iisto redirect 301 to www.qqzer.com for 404.html. The procedure is the same as step 1. In this case, if the user inputs the token interface.

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.

Use ASP/PHP to implement 301 redirection:

ASP:
Response. Status = "301 moved permanently"
Response. addheader "location", "http://www.qqzer.com /"
Response. End

PHP:
Header ("HTTP/1.1 301 moved permanently ");
Header ("Location: http://www.qqzer.com ");
Exit ();

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.