Martin_Thomas_1
Dec 04, 2013Nimbostratus
Replace part of HTTP::host and permanently redirect
I'm looking at redirecting various hosts to a new domain.
Example 1: app.olddomain.com to app.newdomain.com Example 2: anotherapp.olddomain.com to anotherapp.newdomain.com
The problem I'm having ...
- Dec 05, 2013
Either (this is probably more efficient);
when HTTP_REQUEST { if {[HTTP::host] ends_with ".olddomain.com"} { HTTP::respond 301 Location "https://[getfield [HTTP::host] . 1].newdomain.com[HTTP::uri]" } }
Or;-
when HTTP_REQUEST { if {[HTTP::host] ends_with ".olddomain.com"} { HTTP::respond 301 Location "https://[string map {olddomain newdomain} [HTTP::host]][HTTP::uri]" } }