gpt4 book ai didi

get - 删除 nginx 重写中的参数

转载 作者:行者123 更新时间:2023-12-02 23:33:00 24 4
gpt4 key购买 nike

重新启动后我正在重写 nginx 中的 URL。在旧网站中,我在 URL 中有查询参数来过滤内容,例如

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

新页面没有此类参数。我想删除它们并重写主页的 URL,这样我就得到:

http://www.example.com/mypage/

我在nginx中的重写规则是:

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

但根据此规则,参数仍会附加。我认为 $ 会阻止 nginx 处理进一步的值...有什么想法吗?所有其他问题都涉及如何添加参数 - 我只想删除我的:)

最佳答案

有一个类似的问题,经过大量搜索后,答案出现在rewrite docs中.

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

因此,对于您的示例,这可以解决问题:

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

关于get - 删除 nginx 重写中的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9641603/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com