Robert_47833
Sep 29, 2011Altostratus
set variables or not,this is the question
I want to redirect
http://www.cjj.co.uk to http://my.cjj.co.uk
http://www.cjj.com to http://my.cjj.com
hmm
there are 2 ways to achieve this ,one use variable ,another one doesn't
which one is better?
1:when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] {
"/aaaa*"
{ if { [HTTP::host] ends_with ".co.uk" } {
HTTP::redirect "https://my.1.cjj.co.uk"
}
elseif { [HTTP::host] ends_with ".com" } {
HTTP::redirect "https://my.1.cjj.com"
}
}
"/bbbbb"
{ if { [HTTP::host] ends_with ".co.uk" } { HTTP::redirect "https://my.1.cjj.co.uk" } elseif { [HTTP::host] ends_with ".com" } { HTTP::redirect "https://my.1.cjj.com" }
2:
if { [string tolower [HTTP::host]] ends_with ".co.uk" } {
set envdomain "[domain $host 3]"
} elseif {
[string tolower [HTTP::host]] ends_with ".com"
}
{
set envdomain "[domain $host 2]"
}
if {[string tolower [HTTP::uri]] starts_with "aaaa"} {
HTTP::redirect
}
esleif {
[string tolower [HTTP::uri]] starts_with "bbbb"
}
{
HTTP::redirect https://my.$envdomain
}
xxxxxxxxxxx