homepage Welcome to WebmasterWorld Guest from 54.161.190.9
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
RewriteMap vs. RewriteCond
Bluesplinter




msg:3272022
 11:25 pm on Mar 5, 2007 (gmt 0)

I'm using Apache 2.2.4 on a Win2k3 server. I have a number of urls in the format: domain.com/topic/ that I need to rewrite. Exactly 25 of those urls need to be handled by one script. Hundreds of urls need to be handled by a separate script.

Regex alone isn't sufficient to pick out the 25 from the rest, since they follow the same pattern. There are a number of ways to handle this, including the following:

1) Use a txt RewriteMap with the 25 url keys. One thing that feels icky about this is that all 25 would return the same value, no matter which key was looked for.

2) Chain 25 RewriteCond directives together. If one of them hits, then the following RewriteRule will rewrite to the proper script, otherwise the next RewriteRule can use the other script. Of course, this will clutter up the conf file.

One drawback for the RewriteMap method, is that I can't find a Windows tool to generate a dbm file from the text map. I tried to use the perl script from the Apache docs, but it left me with two files (map.db.pag and map.db.dir), and no instructions on what to do with those two files...

Anyway, both of these methods will work (and yes, I know I could always handle it in-script), but of these two ways, which is better? Which is more efficient/faster, etc?

<added>
The RewriteMap method will also allow me to use the default value to handle the alternate script, so I'm leaning towards RewriteMap unless there is a major reason that chained RewriteCond's are better. The only thing that is really making me hesitate is having to use a text map... if you know of a Windows method for converting to a dbm, that'd be great :)

[edited by: Bluesplinter at 11:34 pm (utc) on Mar. 5, 2007]

 

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