httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Bannister <is...@jellybaby.net>
Subject Re: Improving The RewriteMap Program Feature
Date Sun, 02 Mar 2014 16:46:54 GMT
On 1 Mar 2014, at 12:20, Eric Covener <covener@gmail.com> 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 – isoma@jellybaby.net


Mime
View raw message