Re: oops (was: Any Apache mod_rewrite experts out there?)

From: Joe Hourcle <oneiros_at_nyob>
Date: Mon, 18 May 2015 13:45:57 -0400
To: CODE4LIB_at_LISTSERV.ND.EDU
On Mon, 18 May 2015, Karl Holten wrote:

> As Joe cautioned might happen with the N directive, I get an infinite loop from this. It keeps prepending the domain name so you get http://www.google-com.topcat.switchinc.org/http://www.google-com.topcat.switchinc.org/<http://www.google-com.topcat.switchinc.org/http:/www.google-com.topcat.switchinc.org/>/ after the second pass, after the third pass you get the full domain three times and so on.
>
> My not-so-genius solution to this problem is just to put in the same 
> RedirectRule 6 times in a row and skip the N directive.


If you know how many you're dealing with, but don't want it to pass 
through quite as many rules, you can use a power of twos trick:

1. Have a rule that replaces 4 dashes
2. Have a rule that replaces 2 dashes
3. Have a rule that replaces 1 dash

it'll then handle between 0 and 7 dashes.

At 6, this might not be worth it ... when you start getting above a dozen 
(which hopefully you'll never have to deal with), it might be.

-Joe
Received on Mon May 18 2015 - 13:48:10 EDT