我需要将包含查询字符串的url重定向/重写到同一个url,但没有查询字符串。例如http://domain.com/a-post-title/?fbid=xyz到http://domain.com/a-post-title/ 抱歉我的英语不好。
答案 0 :(得分:3)
很简单,只需在重写结束时加?
,
来自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