加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

如何在NgInX中将带有查询字符串的URL重定向到没有查询字符串的UR

发布时间:2020-12-13 20:53:01 所属栏目:Nginx 来源:网络整理
导读:我需要将包含查询字符串的URL重定向/重写为相同的URL,但没有查询字符串.例如http://domain.com/a-post-title/?fbid=xyz至http://domain.com/a-post-title/ 对不起,我的英语不好. 最佳答案 容易,只需放一个?在您重写的最后, 从http://nginx.org/en/docs/http

我需要将包含查询字符串的URL重定向/重写为相同的URL,但没有查询字符串.例如http://domain.com/a-post-title/?fbid=xyz至http://domain.com/a-post-title/
对不起,我的英语不好.

最佳答案
容易,只需放一个?在您重写的最后,
从http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite开始:

If a replacement string includes the new request arguments,the previous request 
arguments are appended after them. If this is undesired,putting a question mark at the 
end of a replacement string avoids having them appended

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读