Website Technology---301 redirect

Source: Internet
Author: User
Tags deprecated domain name server

Permanent page removal (301 redirects ) is a very important "auto-steering" technology. One of the most feasible ways to redirect URLs. When a user or a search engine makes a browse request to the Web server, one of the status codes in the header information in the HTTP data stream returned by the server indicates that the page is permanently transferred to another address.

Domain Orientation

The change of routing is also a redirect to the data message through the path. In our website construction, often encountered the need to redirect the page situation: like the site adjustment, changed the directory structure of the site, the page was moved to a new address. or the page extension changes, such as because the application needs to change. php to. html or. shtml, in these cases, if you do not redirect, then the user favorites or search engine database in the old address can only give access to the customer to get a 404 page error message, access traffic lost in vain. For example, some sites that register multiple domain names also need to redirect users who access these domain names to the primary site, and so on. Way IntroductionCommon redirection methods are: 301 Redirect, 302 redirect and Meta fresh:301 redirect::301 represent permanent transfers (permanently Moved), 301 redirection is the best way to search engine friendly after changing the address of a webpage, as long as it is not temporarily moved, it is recommended to use 301来 to do the forwarding. 302 redirect::302 represents a temporary transfer (temporarily Moved), in previous years, many black Hat seo has been widely used in this technology cheat. Major search engines have intensified the crackdown, like Google's punishment for the BMW German website. Even if the site is not objectively spam, it is easy to be the search engine misjudged spam and punished. Meta Fresh: This is more popular 2000 years ago, it is specifically through the meta-instructions in the Web page, redirected to a new page after a certain time, if the delay time is too short (about 5 seconds), it will be judged as spam. IIS Server implementation 301 redirect* Open Internet Information Services Manager and right-click on the page or directory you want to redirect

IIS6.0 above 301 redirect Map

, select Redirect to URL, * here to redirect to Baidu for example * Enter the URL address of the destination page you want to jump to in the redirect to input box * check "persistent redirection of resources" (remember) * Finally click "Apply" Apache Server implementation 301 redirectBy contrast, Apache is much simpler to implement than IIS. In Apache, there is a very important file. htaccess, with its settings, can achieve a lot of powerful features, 301 redirects just one of them. REDIRECT permanent/index.php http://www/index.php?go=category_6 (redirect Web index.php to http://www./index.php?go= Category_6) more complex matches can be achieved by properly configuring regular expressions in the redirect parameters. Interested friends can refer to the Apache Manual of this site. PHP 301 redirects under<? Header ("http/1.1 301 Moved permanently"); Header ("Location:http://www"); exit; > 301 redirects under ASP<%@ Language=vbscript%><%
    1. status= "301 Moved Permanently"
    2. AddHeader "Location", "HTTP//"
%> ASP. Net of 301 redirects<script runat= "Server" >private void Page_Load (object sender, System.EventArgs e) {
    1. Status = "301 Moved permanently";
    2. AddHeader ("Location", "http://www");
}</script> 301 redirects under ColdFusion<.cfheader statuscode= "301" statustext= "Moved permanently" ><.cfheader name= "Location" value= "http://www." > old domain Redirect to a new domain name create a. htaccess file and write the code provided below to the file, which ensures that all directories or pages of the old domain are correctly redirected to the new domain name. Remember that the. htaccess file must be placed in the root of the old site, and the new site will keep the same directory structure and Web files as the old site. Options +followsymlinksrewriteengine onrewriterule (. *) http://www/$1 [r=301,l] Please change the above wwwdomaincom to the domain you want to jump to. In addition, I recommend that you which comes the external links of the old site and contact the appropriate site to modify the URL of the import chain to point to the new site. Note: the. htaccess file only works on a Linux host that uses Apache as a Web server with the MoD rewrite module installed. Domain 301 Redirect to the WWW level two domain nameThe first thing to know is that www. is a two-level domain name under the domaincom domain. 301 Jump to the implementation of the WWW two domain: Create a. htaccess file and write the code provided below into the file, which ensures that all requests from the domaincom are diverted to the WWW request. Remember that the. htaccess file must be placed in the root of the old site, and the new site will keep the same directory structure and Web files as the old site. Options +followsymlinksrewriteengine Onrewritecond%{http_host} ^ [Nc]rewriterule ^ (. *) $ http://www./$1 [L,R=301] Please change the domaincom above to the domain you want to jump to. Note: the. htaccess file only works on a Linux host that uses Apache as a Web server with the MoD rewrite module installed. using Web. config to implement 301 redirects under ASPIf the Web site root directory does not have Web. config, create a new text document, save it as Web. config, as follows:<configuration><system.webserver><rewrite> <rules><rule name= "WWW Redirect" stopprocessing= "true" ><match url= ". *"/><conditions>< Add input= "{http_host}" pattern= "^$"/></conditions><action type= "Redirect" Url= "http://www/{r:0}" Redirecttype= "Permanent"/></rule></rules></rewrite></system.webserver></ Configuration> upload this web. config to the Web site root directory. Don't forget to replace the above domaincom with your domain name Oh! The prerequisite is that the IIS version of the window host must be 7.0 or higher. How to set up 301 in a blogHere, take Z-blog as an example to explain in detail:
    1. Copy the code below and "Change it to your own URL."
If request. ServerVariables ("SERVER_NAME") "Then
    1. status= "301 Moved Permanently"
    2. AddHeader "Location", "" "
    3. End
End If
    1. Enter the Z-blog background to open the "File Management" interface.
    2. Locate and open the Default.asp file under the root directory of the Web site.
    3. Add the above code to the default.asp shown in the Red box.
    4. 5. Finalize the error click--Submit--Save


1. How the Web server responds to Web browsing requestsLet's take a look at the first interactive process for users/search engines and websites. When a user or search engine issues a web browsing request to a Web server, the server will:
  1. Convert the domain name to the IP address of the website through the domain name server (DNS) and return it to the customer;
  2. Open an IP socket interface connection;
  3. Make a note of an HTTP data stream through the set of interfaces;
  4. Receives an HTTP data stream that responds to a request from the Web server. The data stream contains the status code, and the value of the status code is determined by the HTTP protocol. The "HTTP Data Flow" message is also called header information. The header information includes the date, server type, and usually a "OK" message. If all is well, then the Web server sends the "OK" message and the request page. If the site has already been redirected at this time, the server will include a response message such as "302 Moved temporarily" or "301 Moved Permanent" in the header information. The search engine will make decisions based on the contents of the server header information.
When to use 301 redirect 1. Domain name expires do not want to renew, want to change a domain name. 2 search results in the search engine appeared in the domain name without www, and the domain name with www not included, this time we can use 301 redirect, to tell the search engine our target domain name is. 3. The space server is unstable, when changing space. 301 Redirect and 302 Jump Dip decompositionWhen we do the website, we often legend rumors of 301 and 3,022 kinds of jump compilation, of course, as long as a character differences but there is a great difference in the search engine premises. Each of us an old URL discarded, can not be put on, and to go through a jump, link to the new address, one can pass the weight, and can also be able to prevent this address by the search engine mistakenly touch dead link (address failure), Or 304 status code is not updated for a long time (the corresponding page is still in the long-time not updated). The former for the search engine is undoubtedly a very bad influence, and then do not jump can not be hard. When the need to do jump, there are two kinds of can be selected. 301 and 302. Many people feel that they are universal, or otherwise. 301 jump to find engine is a control of the docility jump, but also the search engine can encounter the jump, it tells the search engine, this address is deprecated, and always turn to a new address. But 302 is no different. 302 is a kind of and then redirect, we should touch such a phenomenon, the domain before the search engine to open a novel page, but the effect of the pop-up is a Sell clothes Mall Web page. This is a very serious cheat. At the moment, the Baidu algorithm upgrade to find the efficacy of the very few flash such a page, but Baidu has this type and then redirect counts as and hijack jump not different. In the search engine it seems like a cheat. So when we do the page jumps must face, the use can not be 302 redirect, but 301 redirect. Domain name expires do not want to renew, want to change a domain name. 2 search results in the search engine appeared in the domain name without www, and the domain name with www not included, this time we can use 301 redirect, to tell the search engine our target domain name is. 3. The space server is unstable, when changing space. 301 Redirect and 302 Jump Dip decompositionWhen we do the website, we often legend rumors of 301 and 3,022 kinds of jump compilation, of course, as long as a character differences but there is a great difference in the search engine premises. Each of us an old URL discarded, can not be put on, and to go through a jump, link to the new address, one can pass the weight, and can also be able to prevent this address by the search engine mistakenly touch dead link (address failure), Or 304 status code is not updated for a long time (the corresponding page is still in the long-time not updated). The former for the search engine is undoubtedly a very bad influence, and then do not jump can not be hard. When the need to do jump, there are two kinds of can be selected. 301 and 302. Many people feel that they are universal, or otherwise. 301 jump to find engine is a control of the docility jump, but also the search engine can encounter the jump, it tells the search engine, this address is deprecated, and always turn to a new address. But 302 is no different. 302 is a kind of and then redirect, we should touch such a phenomenon, the domain before the search engine to open a novel page, but the effect of the pop-up is a Sell clothes Mall Web page. This is a very serious cheat. At the moment, the Baidu algorithm upgrade to find the efficacy of the very few flash such a page, but Baidu has this type and then redirect counts as and hijack jump not different. In the search engine it seems like a cheat. So when we do the page jumps must face, the use can not be 302 redirect, but 301 redirect.

Website Technology---301 redirect

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.