Forum Discussion
Stanislas_Piro2
Apr 30, 2016Cumulonimbus
Hi,
instead of multiple if commands, it is recommended to use switch
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "mysite.com" } {
switch -glob [string tolower [HTTP::path]] {
"/" -
"/mysite/" { HTTP::redirect https://www.bettersite.com/mysite/ }
default {
HTTP::redirect https://www.bettersite.com/mysite[HTTP::uri]
return
}
}
} else { HTTP::respond 301 Location https://www.mysite.com[HTTP::uri] return }
}
when appending [HTTP::uri] to a host, do not add / as [HTTP::uri] already starts with /