Forum Discussion
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
- HamishCirrocumulusI'd run timings myself to see which one actually comes out quicker. But asthetically 2 reads better...
- Robert_47833AltostratusthankS,i ask this because it seems link below doesn't suggest us to use variables
- Michael_YatesNimbostratusHi Jucao,
- Robert_47833Altostratusok,it seems they have same efficiency
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects