iRules - multiple matches
I'm new to iRules so need your help on fine tune of my iRule below.
We are having serveral domain and subdomain and forward to same VS on F5. F5 will need to examine the HTTP REQUEST and redirect the request to correct location:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] eq "www.xyzabc.com"} {
if { [string tolower [HTTP::uri]] eq "/" } {
this will redirect www.xyzabc.com to below URL
HTTP::redirect "https://www.xyzabc.com/xyz/web_portal/web/home/"
}
}
if { [string tolower [HTTP::host]] eq "xyzabc.com"} {
if { [string tolower [HTTP::uri]] eq "/" } {
HTTP::redirect "https://www.xyzabc.com/xyz/web_portal/web/home/"
}
}
if { [string tolower [HTTP::host]] eq "hd.xyzabc.com"} {
if { [string tolower [HTTP::uri]] eq "/" } {
this will redirect www.xyzabc.com to below URL
HTTP::redirect "https://www.xyzabc.com/xyz/web_portal/web/thuchanh_xyz/"
}
}
if { [string tolower [HTTP::host]] eq "www.hd.xyzabc.com"} {
if { [string tolower [HTTP::uri]] eq "/" } {
this will redirect xyz.biz to below URL
HTTP::redirect "https://www.xyzabc.com/xyz/web_portal/web/thuchanh_xyz/"
}
}
if { [string tolower [HTTP::host]] eq "kyso.xyzabc.com"} {
if { [string tolower [HTTP::uri]] eq "/" } {
HTTP::redirect "https://kyso.xyzabc.com/digitalsign/web/"
}
}
if { [string tolower [HTTP::host]] eq "www.hd.xyzabc.com"} {
if { [string tolower [HTTP::uri]] eq "/" } {
HTTP::redirect "https://kyso.xyzabc.com/digitalsign/web/"
}
}
}
This is the iRule for HTTP Virtual Server and I applied the same with HTTPS VS (the main reason is all http request will need to be redirected to HTTPS).
This iRules' working but I found that for the 2 if, I should compose to 1 if { xxx and yyy} but did not succeed. Will this cause the iRule to be proccessed slowly? Are there any way to optimize the iRule so it can work faster?
Thanks and Best Regards,
Khoa