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 XXX
is some can of variable thing?
精彩评论