Re: Any Apache mod_rewrite experts out there?

From: James Morley <James.Morley_at_nyob>
Date: Fri, 15 May 2015 20:46:54 +0000
To: CODE4LIB_at_LISTSERV.ND.EDU
Used to have a contractor in my last job who was a wizard at this sort of thing when we did a big migration. Might be one worth posting on Stack Overflow?

Good luck.

________________________________________
From: Code for Libraries [CODE4LIB_at_LISTSERV.ND.EDU] on behalf of Karl Holten [kholten_at_SWITCHINC.ORG]
Sent: 15 May 2015 20:04
To: CODE4LIB_at_LISTSERV.ND.EDU
Subject: [CODE4LIB] Any Apache mod_rewrite experts out there?

My organization is changing proxy servers from WAM to EZproxy, and we would like to give staff time to change over their URLs before we make the switch. I would like to set up forwarding so the links using the new proxy get redirected to the old proxy. I'm planning on using apache's mod_rewrite to do this.

Basically, this mod rewrite rule needs to do three things:
1) Change the part of the domain name (not the file path) that reads "ezproxy.switchinc.org" to our old domain "topcat.switchinc.org"
2) Append the prefix "0-" in front of the domain name
3) Transform dashes in the domain name to periods.

Could anyone provide me with some assistance? I am sure this takes maybe 10 lines of code from a mod_rewrite expert, but it has taken me several weeks to the first two objectives done, and all of my google fu is failing me for objective three. Below is what I have:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)ezproxy.switchinc.org [NC]
RewriteRule ^(.*) %{HTTP_HOST}/$1 [DPI]
RewriteRule ^(.*)ezproxy.switchinc.org/(.*) http://0-$1topcat.switchinc.org/$3 [L]

Thanks,
Karl Holten
Systems Integration Specialist
SWITCH Inc
414-382-6711
Received on Mon May 18 2015 - 05:07:26 EDT