homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

In RedirectMatch how to split second parameter?

Msg#: 4621234 posted 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



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

Msg#: 4621234 posted 10:07 pm on Nov 5, 2013 (gmt 0)

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?


Msg#: 4621234 posted 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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved