Hi Tim That could be an alternative way to implement it.
I would say that one advantage of my way is that we are just adding support for the default value meaning that the fallback doesn't have to be a program. For what we would be using this for either solution would work. I must admit it does seem like a flaw in the original implementation of the feature not to handle the program failing. Kev > On 2 Mar 2014, at 16:46, Tim Bannister <[email protected]> wrote: > > On 1 Mar 2014, at 12:20, Eric Covener <[email protected]> wrote: > >>> If the RewriteMap Program fails, the code within mod_rewrite returns an >>> empty string rather than NULL. In my tests this caused /index.htm to be >>> returned as the URL which is not very useful. I think it makes more sense to >>> handle this situation as a NULL so that the default key is used as we could >>> then provide a backup method. >>> eg: >>> RewriteRule ^/proxy/(.*) ${proxymap:$1|/proxybackup/$1} [P] >>> RewriteRule ^/proxybackup/(.*) /proxybackup.php?url=$1 [L] >>> >>> Looking at the mod_rewrite source code this appears to be a one liner change >>> in lookup_map_program: >>> if (i == 4 && !strcasecmp(buf, "NULL")) >>> ..... >>> becomes: >>> if ((i == 0) || (i == 4 && !strcasecmp(buf, "NULL"))) { >>> ..... >>> >>> Is this minor change something that you would consider implementing? >> >> I think it would need to be opt-in in 2.4, as changing it could break >> configs depending on the current behavior. Maybe some extra flag on >> the definition of the RewriteMap or a RewriteOption? > > Here's how I'd want it: > > RewriteMap foo prgfb:/www/bin/example.pl > > (prgfb — program with fallback). > > > I can write and submit a patch for this if there's interest. > > -- > Tim Bannister – [email protected] >
