Tyranon_113005
Jan 15, 2018Nimbostratus
HTTP redirect by HOST and URL
Hello,
I'm trying redirect HTTP request depends on HTTP host and url.
Example,
https://www.aaa.com/123 -> https://www.bbb.com/specified1
https://www.aaa.com/456 -> https://www.bbb.com/specified2
https://www.aaa.com/* -> https://www.aaa.com/*
https://www.bbb.com/* -> https://www.bbb.com/*
Does the below work as I expected?
when HTTP_REQUEST {
if { [HTTP::host]] equals "www.aaa.com"}{
switch [HTTP::uri] {
"/123" { HTTP::redirect "https://www.bbb.com/specified1" }
"/456" { HTTP::redirect "https://www.bbb.com/specified2" }
}
default {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
}
}
elseif { [HTTP::host] equals "www.bbb.com" }{
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
}
}