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. Not optimal, but this 
seems to work fine:



RewriteEngine on

RewriteCond %{HTTP_HOST} ^(.*)-(.*)ezproxy.switchinc.org

RewriteRule ^(.*) %1.%2 ezproxy.switchinc.org$1

RewriteRule ^(.*)-(.*)ezproxy.switchinc.org(.*) $1.$2ezproxy.switchinc.org$3 (I 
repeated this 5 times)

RewriteRule ^(.*)ezproxy.switchinc.org/(.*) https://0-$1topcat.switchinc.org$2 
[L]



Thanks everyone!



Karl Holten

Systems Integration Specialist

SWITCH Inc

414-382-6711



-----Original Message-----
From: Code for Libraries [mailto:CODE4LIB@LISTSERV.ND.EDU] On Behalf Of Joe 
Hourcle
Sent: Monday, May 18, 2015 8:59 AM
To: CODE4LIB@LISTSERV.ND.EDU
Subject: [CODE4LIB] oops (was: [CODE4LIB] Any Apache mod_rewrite experts out 
there?)



On Mon, 18 May 2015, Joe Hourcle wrote:





>  RewriteRule ^(.*)-(.*)ezproxy.switchinc.org/(.*)

> $1.$2ezproxy.switchinc.org/$3 [N]



I wasn't thinking ... RewriteRule doesn't operate on the full URL, only on the 
non-host portion.  You might need to do strange things w/ RewriteCond and 
RewriteRule instead:



   RewriteCond %{HTTP_HOST} ^(.*)-(.*)ezproxy.switchinc.org

   RewriteRule ^(.*) 
http://%1.%2ezproxy.switchinc.org/$1<http://%251.%2ezproxy.switchinc.org/$1> [N]



The %1 and %2 come from the captures in RewriteCond, while the $1 comes from 
RewriteRule.



-Joe

Reply via email to