Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

In RedirectMatch how to split second parameter?



9:50 am on Nov 5, 2013 (gmt 0)

In RedirectMatch how to split second parameter?

RedirectMatch ^/([a-zA-Z]{5}+)/([a-zA-Z0-9]+\_+[a-zA-Z0-9]+)/((.*)+\.+(png|jpg|jpeg|gif))$ http://google.com/ASVGTY/$2/$3

Second parameter i need to split using underscor(_)..please suggest me

Regards vasanth


10:07 pm on Nov 5, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

I saw the subject line and was all set to reply succintly "NO". But it turns out you don't mean parameter, you just mean one section of the URL. Presumably it turns into a parameter later-- but if so, that means you're using mod_rewrite and must therefore change any and all rules currently using mod_alias (Redirect by that name). But the Regular Expression is the same either way.

An underscore/lowline is \w so you do have to spell it out as you've done: [a-zA-Z0-9]+ That's assuming your URLs really do use both capital and lower-case letters. A lowline never needs to be escaped.

Why don't you simply open and close the grouping parentheses? (blahblah)_(blahblah) That changes $2 into $2 and $3, while the old $3 becomes $4.

I suspect there is more to the question than you've said, though. Among other things, what does the target really mean? As written, the rule makes a temporary redirect; that's the default if you don't say "Permanent" or "301".


The parentheses around .* are superfluous if you're not capturing separately. Anyway, you want
to stop capturing before the extension, and + rather than * Otherwise you're allowing filenames in the form ".jpg" and that's all. Is there any possibility of subdirectories in this last part?


6:02 am on Nov 6, 2013 (gmt 0)

RedirectMatch ^/([a-zA-Z]{5}+)/([a-zA-Z0-9]+)(\_+)([a-zA-Z0-9]+)/((.*)+\.+(png|jpg|jpeg|gif))$ http://abcd.com/dfgsdf/$4/$5

Now working perfectly.Thank you

Featured Threads

Hot Threads This Week

Hot Threads This Month