Remove parameters within nginx rewrite

前端 未结 4 1934
春和景丽
春和景丽 2020-12-09 09:09

I\'m rewriting URLs in nginx after a relaunch. In the old site I had query parameters in the URL to filter stuff e.g.

http://www.example.com/mypage.php?type=         


        
4条回答
  •  孤城傲影
    2020-12-09 09:54

    Had a similar problem, after a lot of searching the answer presented itself in the rewrite docs.

    If you specify a ? at the end of a rewrite then Nginx will drop the original $args (arguments)

    So for your example, this would do the trick:

    location ^~ /mypage.php {
        rewrite ^/mypage.php$ http://www.example.com/mypage? permanent;
    }
    

提交回复
热议问题