301 302 304

Source: Internet
Author: User

301,302 differences
301 redirect: 301 indicates that after a permanent transfer (permanently moved) request is sent, the server informs the client browser that the request is permanently redirected and no remote server is requested the next time the webpage is requested, the client browser caches the redirection destination address. However, if the browser clears the cache, the browser redirection will become invalid and you need to request the server again.

302 redirect: 302 indicates the temporary transfer (temporarily moved). Each time the client browser requests the server, the server returns 302, and the client browser then requests the corresponding URL based on the response header.

Usage differences:
301 redirection is the best method for search engine-friendly webpage address change. As long as it is not temporarily moved, we recommend that you use 301 for address conversion.

Q: Where is the cache for search engines?
SEO (Search Engine Optimization): If an address is redirected in the 301 redirection mode, the search engine will take PageRank and other information of the old address to the new address, in the search engine index library, old addresses are discarded completely.

302 redirection is a temporary transfer.
In the past few years, many black hat SEO have widely used this technology to cheat. At present, major search engines have strengthened their efforts and are mistaken for spam)

Page Jump Mode
Various HTML page Jump Methods
1. Meta Refresh jump. The Code is as follows:
<Meta http-equiv = "refresh" content = "5; url = http://www.baidu.com">
The number in the content is the number of seconds, indicating that the page will jump after a few seconds. The URL attribute value is the page to jump.

2. Javascript jump. The Code is as follows:
<Script language = "JavaScript" type = "text/JavaScript"> window. Location. href = "http://www.baidu.com"; </SCRIPT>
It is not easy to be seen by search engines as a jump

Redirection of programming languages
Different programming languages are redirected through the Redirect provided by Alibaba Cloud.
Various code implementations:
1) JSP redirect jump: Response. sendredirect ("test. jsp ");
2) Asp redirect jump: Response. Redirect "test. asp"
3) PHP redirect jump: Header ("Location: test.html ");
4). Net redirect jump: Response. Redirect ("test. aspx ");
With status code 302

301 jump
1) Web server configuration 301 jump.
Apache 301 redirection configuration. The Code is as follows:
Redirect 301 "/a.htm" http://www.a.com/a/
The previous page is the jump Source Page, and the latter is the jump target page.
2) 301 jump of the dynamic program. In addition to Web servers, you can set 301 redirection. in this province, the language also provides the 301 redirection function. Different implementation statements:
A) The ASP code is as follows:
Response. Status = "301 moved permanently"
Response. addheader "location", "Your 301 destination URL"
B) the PHP code is as follows:
Header ('HTTP/1.1 301 moved permanently ');
Header ("Location: http://www.wenjuntech.com ");
C). Net code:
Response. Status = "301 moved permanently ";
Response. addheader ("location", "301 Address URL ");
D) the JSP code is as follows:
Response. setstatus (301 );
Response. setheader ("location", "301 URL ");
Response. setheader ("connection", "close ");
For page url changes caused by website migration or upgrade, it is best to use the 301 jump method, because the 301 jump can be effectively recognized by the search engine, PageRank will inherit the original website, it is more conducive to Seo.


HTTP status codes for different redirect Methods
The HTTP status code is 200 jump:
Method 1: Response. Redirect ("test. aspx ");
Status Code 301 temporary jump
Method 2: <meta http-equiv = "refresh" content = "5; url = test. aspx"/>
Meta fresh: It was widely used in earlier years and is rarely used now. The meta command in the webpage redirects to the new webpage after a specific time. If the delay is too short (within 5 seconds), it is determined as spam. In this method, the HTTP status is 200.
Method 3: Server. Transfer ("test. aspx ");
The HTTP status is 200.
Method 4: urlrewrite
The HTTP status is 200.
Encoding for 301 redirection
Response. Status = "301 moved permanently ";
Response. addheader ("location", "http://www.baidu.com ");

 

301

<?phpob_start();echo ‘xxxxxxxxxxxxx‘;header(‘HTTP/1.1 301 Moved Permanently‘);header(‘location:http://www.qq.com‘);echo ‘6666666666666666666‘;

 

302

<?phpob_start();print ‘xxxxxxxxxxxxx‘;header(‘Location: http://www.baidu.com/‘);print ‘ttttttttttttttttttt‘;

 

 

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.