开发者

Redirect If URL Param Contains Specific Substring Value

I'm trying to use mod_rewrite to redirect users coming with a certain substring in their URL.

For example, INBOUND_XXX34_MPEG, if 34 is in the URL, I need to redirect to a different integer (i.e.: INBOUND_XXX20_MPEG)

Is this type fine tooth-combing possible with mod_rewrite?

EDIT what I have so far, but fails in testing:

开发者_开发问答RewriteEngine on
RewriteRule ^(.*=\w*)34(.*)$ $120$2


Solved it!

RewriteCond %{QUERY_STRING} linkid=(.*)34(_.*)$
RewriteRule (.*) $1?linkid=%120%2 [R=301,L]

This will preserve URI, additional query params, and target the substring index.


I'm not sure about what you really want but how about this:

RewriteRule ^(.*)INBOUND_XXX34_MPEG(.*)$ $1INBOUND_XXX20_MPEG$2

I do not know if the XXXis some can of variable thing?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜