DM_5174
May 23, 2011Nimbostratus
merging two irules into one efficient one.
Hi All,
I was wondering if there is a way to merge two irules into one effcient one. The first irule checks the host
and if a user is coming in as www.mysite.com, it will rewrite the host header to www.mynewsite.com, and if nothing matches, it should redirect all inbound http request to httpS.
The second irule uses a datagroup string that matches the URI. so if the users puts in
http://www.mynewsite.com/abc/app1 they will get redirected to http://www.mynewsite.com/123/app100
Thanks!
-DMiRule 1
when HTTP_REQUEST { Check if the Host is www.mysite.com
if { [string tolower [HTTP::host]] eq "www.mysite.com"} {
Rewrite the Host header to www.mynewsite.com
HTTP::header replace Host "www.mynewsite.com"
} else {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
}
}
iRule 2
when HTTP_REQUEST {
look for the second string in the data group and redirect
set newURI [findclass [HTTP::uri] $::newURI-Datagroup " "]
if { "" ne $newURI } {
HTTP::redirect "https://www.mynewsite.com/$newURI"
}
}