Hi:- these are the first iRules i am trying to write.
I need to write 2 IRules the need to reference the same information theough different conversations.
the first needs to redirect a URL t oa new site but keep the original serverxx information. serverxx will be one of up to 16 servers so xx will be server01, server02… server16. For brevity i have only added two servers to the second iRule.
I need to change the URL of the initial conversation from
serverxx.sub.mysite.com/info_need_to_be_kept
To
mysite.com/nextserver/info_from_above + serverxx
The nextserver site does not reference the URI query information so I can add the serverxx to the end of the query.
I have this iRule:
when HTTP_REQUEST {
Check if path contains “server”
if { [string tolower [HTTP::path]] contains “server”}
set serverxx [getfield [HTTP:host] “.” 1]
set uri [HTTP:uri]
Redirect to mysite.com/nextserver/info_need_to_be_kept
but add the “serverxx” at the end of the query
HTTP::redirect mysite.com/nextserver/$uri$serverxx
}
The second iRule needs to change the site back to the original site with the uri information minus the added serverxx.
I have:
when HTTP_REQUEST {
Check if uri query contains the word nextserver if it does then get the word server + 2 characters from the end of the uri
if { [string tolower [HTTP::query]] contains “server”}
set serverxx [string range [HTTP:query] server 0 8]
set uri [findstr [HTTP:uri] nextserver server]
~~Redirect to https://serverxx.sub.mysite.com/info\_need\_to\_be\_kept~~
~~HTTP::redirect https://$serverxx.sub.mysite.com$uri~~
if { [HTTP::path] contains “server01” } {
node 10.10.10.1:80
} elseif [HTTP::path] contains “server02”}
node 10.10.20.1:80
}
}
else {
pool Server_Pool
}
}
thank you,
mark.