Forum Discussion
Robert_47833
Sep 26, 2011Altostratus
Hi,how to set domain in this situation
Dear irule
in one irule,there are 2 types request
https://1.cjj.com/aaaa
https://1.cjj.co.uk/aaaa
I want to redirect them to my.1.cjj.com or .co.uk
elseif {$uri starts_with "/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
}
my question is :
because there are 4 other places in this irule need use redirect this types uri
should I configure something like this to avoid use if /elseif in each condition
set domain [domain [HTTP::host] 2]
but in order to handle 1.cjj.com and 1.cjj.co.uk together ,how to achieve this?
if {HTTP::host] ends_with ".co.uk} {
set domain [domain [HTTP::host] 3]
}
elseif {HTTP::host] ends_with ".com} {
set domain [domain [HTTP::host] 2]
}
is this one right?
do u have someone who is better than mine,pls show me
Thanks in advance
- Michael_YatesNimbostratusHi jucao,
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" } } "/bbbb*" { HTTP::redirect "http://www.google.com" } "/cccc*" { HTTP::redirect "http://www.yahoo.com" } } }
- Robert_47833Altostratushmmm,thanks,Michael
- Robert_47833Altostratushmmm,thanks,Michael
- Robert_47833Altostratushow about this one?
- Michael_YatesNimbostratusHi jucao,
when HTTP_REQUEST { if { [string tolower [HTTP::host]] ends_with ".co.uk" } { set envdomain "[domain $host 2]" } elseif {[string tolower [HTTP::host]] ends_with ".com" } { set envdomain "[domain $host 1]" } }
- Robert_47833Altostratuscool
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