使用 .htaccess 进行部分 URL 重定向
我需要通过 mod_rewrite 重定向一堆 URL。 URL 结构如下:
www.mysite.com/somescript.php?&lang=asp&variable1&variable2
需要重定向到
www.mysite.com/somescript.php?&lang=php&variable1&variable2
因此,基本上,任何包含 &lang=asp 的 URL 都需要重定向到完全相同的 URL,但包含 &lang= php 替换 &lang=asp。
有没有办法通过 .htaccess 来做到这一点,也许使用某种通配符?
非常感谢,我将非常感谢你的帮助。
干杯,
马特
I'm need to redirect a a bunch of URL's through mod_rewrite. The URL structure is as follows:
www.mysite.com/somescript.php?&lang=asp&variable1&variable2
Needs to redirect to
www.mysite.com/somescript.php?&lang=php&variable1&variable2
So, basically, any URL with &lang=asp in it needs to be redirected to exactly the same URL but with &lang=php replacing &lang=asp.
Is there a way I can do this through .htaccess, perhaps with some sort of wildcard?
Thanks alot, I would appreciate your help.
Cheers,
Matt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
修改查询字符串
访问 /path 时,将查询字符串中 val 的任何单个实例更改为 other_val。请注意,%1 和 %2 是对先前 RewriteCond 中正则表达式的匹配部分的反向引用。
阅读此页面了解更多信息 http://wiki.apache.org/httpd/RewriteQueryString
Modifying the Query String
Change any single instance of val in the query string to other_val when accessing /path. Note that %1 and %2 are back-references to the matched part of the regular expression in the previous RewriteCond.
Read this page for more info http://wiki.apache.org/httpd/RewriteQueryString