【发布时间】:2015-08-11 23:03:52
【问题描述】:
目前,我正在使用 WordPress 中的 Redirection 插件以这种方式重定向所有包含 q 问号的 URL:
Source: /(.*)\?(.*)$
Target: /$1
这很好用。它将重定向任何带有? 的链接,例如/good-friends-are-great.html?param=x 到/good-friends-are-great.html。
但是,现在我需要破例。我需要允许 /friends 传递 GET 参数,例如/friends?guest=1&event=chill_out&submit=2 OR /friends/?more_params,不截断参数。
我已经尝试将插件中的正则表达式修改为:
Source: /(?!friends/?)\?(.*)$
Target: /$1
但这没有用。使用上面的表达式,任何带有? 的链接都不再被重定向。
你能帮忙吗?
【问题讨论】:
标签: php regex wordpress redirect