使用.htaccess进行部分URL重定向
我需要通过mod_重写重定向一堆URL。URL结构如下所示:使用.htaccess进行部分URL重定向,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我需要通过mod_重写重定向一堆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 有没
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实现这一点,或者使用某种通配符
非常感谢,我会感谢你的帮助
干杯
Matt修改查询字符串 访问/path时,将查询字符串中的任何单个val实例更改为其他val。请注意%1和%2是对上一次重写中正则表达式的匹配部分的反向引用
RewriteCond %{QUERY_STRING} ^(.*)lang=asp(.*)$
RewriteRule /path /path?%lang=php%2
阅读本页了解更多信息正则表达式不应该是
^(.*)(?:^ |和)lang=asp(?:&$)(.*)$
?它看起来不那么优雅,但只在边界上匹配,所以slang=aspect-oriented
不会改变。