开发者

Partial URL redirect with .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开发者_运维技巧


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.

RewriteCond %{QUERY_STRING} ^(.*)lang=asp(.*)$
RewriteRule /path /path?%lang=php%2

Read this page for more info http://wiki.apache.org/httpd/RewriteQueryString

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜