iRule for single VIP but with multiple pool

 

Here I want to redirect our two websites visitors (en.microsoft.com and ph.microsoft.com) to same public IP but to two different pool.

If someone types en.microsoft.com, LTM needs to redirect to a specific path /en and specific pool name en_pool

If someone types ph.microsoft.com, LTM needs to redirect to a specific path /ph and specific pool name ph_pool

when HTTP_REQUEST {
set myhost [string tolower [HTTP::host]]
set myuri [string tolower [HTTP::uri]]

if {$myhost contains "en.microsoft.com"}
{
    if { [HTTP::path] eq "/"} {
       HTTP::redirect "https://[HTTP::host]/en/"
    pool en_pool
    }
    else { pool en_pool}
}
if {$myhost contains "ph.microsoft.com"}
{
    if { [HTTP::path] eq "/"} {
       HTTP::redirect "https://[HTTP::host]/ph/"
    pool ph_pool
    }
    else { pool ph_pool}
}
else { pool microsoft_pool }
}
iRules APIDescriptionExample
HTTP::uriReturns the URI of the HTTP request. This typically does not include the protocol or hostname, just the path and query string, starting with a slash.example 1: http://itadminguide.com/wp-admin/admin.php?page=tablepress&action=edit&table_id=9

HTTP::uri returns
/wp-admin/admin.php?page=tablepress&action=edit&table_id=9
HTTP::pathReturns Path part of the HTTP request.example 1: http://itadminguide.com/

HTTP:path returns
/

example 2: http://itadminguide.com/wp-admin/admin.php?page=tablepress&action=edit&table_id=9

HTTP:path returns
/wp-admin/admin.php
HTTP::hostReturns host header of the HTTP request along with port but when non-standard port is specified (expect 80 (HTTP) or 443(HTTPS)) example 1: http://www.itadminguide.com/

HTTP::host returns
www.itadminguide.com

example 2: http://itadminguide:7003

HTTP::host returns
itadminguide:7003