重定向.htaccess中的URL,但请保留查询字符串
我想在.htaccess中重定向URL,但要在URL末尾将(Dynamic)参数从查询字符串中保留(例如?ID = 1660
,id = 1661
等),
例如 https://mywebsite.example/service/viewinvoice.php?id = 1660
我想将其重定向到:
https://mywebsite.example.example/whmcs-bridge/? 。
/mywebsite.example/whmcs-bridge/?ccce=viewinvoice.php?id = ...
我在下面尝试过,没有任何成功,
RewriteEngine On RewriteCond %{QUERY_STRING} (^|&)/service/viewinvoice.php?id= [NC] RewriteRule ^/?$ /whmcs-bridge/?ccce=viewinvoice.php [L,R=301]
我认为这不是正确的解决方案。 有人有建议吗?
I want to redirect a URL in .htaccess, but want to keep the (dynamic) parameters from the query string at the end of the URL (e.g. ?id=1660
, ?id=1661
, etc.)
E.g.https://mywebsite.example/service/viewinvoice.php?id=1660
I want to redirect it to:
https://mywebsite.example/whmcs-bridge/?ccce=viewinvoice.php?id=1660
So basically: https://mywebsite.example/service/viewinvoice.php?id=...
needs to be redirected to https://mywebsite.example/whmcs-bridge/?ccce=viewinvoice.php?id=...
I tried this below, without any success
RewriteEngine On RewriteCond %{QUERY_STRING} (^|&)/service/viewinvoice.php?id= [NC] RewriteRule ^/?$ /whmcs-bridge/?ccce=viewinvoice.php [L,R=301]
I think this is not the right solution.
Does someone has suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用
从示例URL中,您无需在重写条件下匹配查询字符串。您正在匹配作为重写规则本身第一部分的URL路径。
您的规则应该是:
You need to use the QSA (Query String Append) flag on your rewrite rule. From the documentation:
From your example URLs, you don't need to match the query string in a rewrite condition. You are matching the URL path which is done as the first part of the rewrite rule itself.
Your rule should be: