Nginx implements permanent (301) (302) redirection

Source: Internet
Author: User

Nginx implements permanent (301) (302) redirection

Popular Science:

301 permanent redirect: when a user or search engine sends a browser request to the website server, one of the status codes in the header information returned by the server in the HTTP data stream indicates that the webpage is permanently transferred to another address.

302 temporary jump is also a status code, meaning that it is temporarily redirected to another URL.

The main difference between the two is that, in a single sentence, 302 is easily regarded as spam by search engines, and 301 won't.

Official nginx rewrite documentation:

Nginx is slightly different from apache rules. This Code redirects lanyingblog.com to www.lanyingblog.com to avoid distribution of Search Engine weights.

If ($ host! = 'Www .lanyingblog.com ') {rewrite ^/(. *) $ http://www.lanyingblog.com/#1 permanent ;}

Add it to the conf configuration file. I usually put it together with the pseudo-static configuration. In the code, if it is not www.lanyingblog.com, it will automatically jump to www.lanyingblog.com. permanent indicates that 301 is a permanent jump, and 302 is a temporary jump if it is changed to redirect.

Related Article

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.