Forum Discussion
Deb_Allen_18
May 29, 2008Historic F5 Account
Ouch, please let's not go with regsub to solve such a simple problem. Very pretty all on one line & everything, but very expensive command to invoke regardless how simple the operation itself might be.
Why not simply use the "domain" command:
when HTTP_REQUEST {
HTTP::redirect "https://www.domain1.com/nsa/+homePage=[domain [HTTP::host] 2]"
}
which will return only the last 2 parts of any domain name.
If you truly need to operate only on those domains with www. prefix, then use the starts_with operator to condition the change as in colin's example:
when HTTP_REQUEST {
if { [HTTP::host] starts_with "www." } {
HTTP::redirect "https://www.domain1.com/nsa/+homePage=[domain [HTTP::host] 2]"
} else {
HTTP::redirect "https://www.domain1.com/nsa/+homePage=[HTTP::host]"
}
}
/deb