开发者

Partial URL redirect with .htaccess

开发者 https://www.devze.com 2023-01-22 04:37 出处:网络
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

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

精彩评论

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