mod_rewrite .htaccess 重定向查询字符串的一部分
我正在努力解决重定向问题。我需要使用 mod_rewrite 彻底将以下 URL 重定向到以下 .htaccess
http://www.mysite.com/somescript.php?&lang=php&var=1&var=2
到以下内容
http://www.mysite.com/somescript.php?lang=php&var=1&var=2
所以,基本上我只需要删除
&
之前的
lang=php
内容但是,顺序很重要。有时
&lang=php
出现在查询字符串中其他变量之后。在这种情况下,我需要
&
保留
&lang=php
这可能吗?
总而言之,如果 &lang=php 出现在查询字符串的开头,则删除 &。如果 &lang=php 出现在查询字符串中的其他位置,则 &必须保留。
希望这一点很清楚!
我会自己更改脚本,但不幸的是我不是开发人员,而且他目前似乎并没有太大帮助;这是一个快速修复。
I'm struggling with a redirect problem. I need to redirect the following URL with mod_rewrite thorough .htaccess
http://www.mysite.com/somescript.php?&lang=php&var=1&var=2
to the following
http://www.mysite.com/somescript.php?lang=php&var=1&var=2
So, basically I just need to remove the
&
before
lang=php
However, the order is important. Sometimes
&lang=php
appears after other variables in the querystring. in this scenario I need the
&
to remain part of
&lang=php
Is this possible?
To summarise, if &lang=php appears at the beginning of the query string, remove the &. If &lang=php appears anywhere else in the query string, the & must remain.
Hope this is clear!
I would change the script myself but unfortunately I am not the developer, and he doesn't seem too helpful at the moment; this is a quick fix.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会将
?&
替换为?
:I would replace
?&
with?
:为什么不匹配
"?&"
并将其替换为"?"
?像这样的东西:(
未经测试)
因为我认为组合
"?&"
永远不会有效......(?)why don't you match
"?&"
and replace it by"?"
?Something like:
(not tested)
Because I think the combination
"?&"
is never valid...(?)