On Wed, 23 Jul 2008, Steve Cayford wrote:

> Tom Penney wrote:
>> [...]
>> I would think this rule would work:
>> RewriteRule ^(.*)/?$ ${txtmap:$1} [L]
>>
>> And it does work for this url:
>> http://domain.com/page/one
>>
>> but does not match this url:
>> http://domain.com/page/one/
>> because the ".*" is gobbling up the trailing slash and not finding it in my map
>>
>> any suggestions?
>
> In perl regexes you can use ".*?" instead of ".*" to make it a 
> non-greedy match. Does that work?


I was going to ask about that too, but I have the impression that you can 
simplify further.  I think maybe this is what you want to handle all 
cases:

RewriteRule ^(([^/]+?/)*[^/]+)/?$ ${txtmap:$1} [L]

I'm not entirely clear on what you are doing, but that will allow for any 
number of initial strings followed by slashes.  So...

itmatchesthis
andthis/
and/it/matches/this
and/it/matches/this/

...and the trailing slash is dropped such that $1 never has a trailing 
slash.  By the way, this might be just as good:

RewriteRule ^(([^/]+?/)*[^/]+)/*$ ${txtmap:$1} [L]

I replaced a question mark with an asterisk to allow any number of 
trailing slashes, all of which are not held in $1.

I don't know if any of this works for you though.

Mike