Nginxpermanent redirection parameters

Source: Internet
Author: User
The project was recently revised and the page was completely static. The original dynamic page needs to be permanently redirected to a static page by 301, so that the search will transfer the weight of the original page to the new static page. If ($ query_string ~ * & Quot; id (\ d +) $ & quot;) {set $ id $1; rewrite...

 

The project was recently revised and the page was completely static.

 

The original dynamic page needs to be permanently redirected to a static page by 301, so that the search will transfer the weight of the original page to the new static page.

 

If ($ query_string ~ * "Id = (\ d +) $ "){

Set $ id $1;

Rewrite ^/goods \. php/goods/$id.html permanent;

}

This redirection finds when the http://www.2cto.com/goods. php? When id = 254 will jump to the http://xxx.com/goods/254.html? Under id = 254

 

The search engine's indexed address is also added with unnecessary parameters. the boss called to remove the following parameters. What should we do?

 

 

 

 

 

For example:

Put http://example.com/test.php? Para = xxx redirection to http://example.com/new

Rewrite ^/test. php (. *)/new permanent;

The result after redirection is: http://www.2cto.com/new? Para = xxx

If it is rewritten to: rewrite ^/test. php (. *)/new? Permanent;

The result is: http://www.2cto.com/new

 

So the key point is "?". This suffix. What if I want to retain a specific parameter? You can use the $ arg_PARAMETER parameter included in Nginx.

 

For example:

Set http://www.2cto.com/test. php? Para = xxx & p = xx rewrite to http://www.2cto.com/new? P = xx

Can be written as: rewrite ^/test. php/new? P = $ arg_p? Permanent;

From small? Too many tasks? /P>

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.