Forum Discussion
Michael_Yates
May 15, 2010Nimbostratus
This one will do exactly what you are asking:
when HTTP_REQUEST {
if { [HTTP::host] equals "www.joe.com" and [HTTP::uri] starts_with "/net/myjoe" } {
HTTP::redirect "https://www.joe.com/net/myjoe"
}
}
I find this way to be a little more elegant and flexible.
when HTTP_REQUEST {
if { [HTTP::host] equals "www.joe.com" and [HTTP::uri] starts_with "/net/myjoe" } {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
}
}
In the first example it will redirect you directly to "https://www.joe.com/net/myjoe", but the second example is a little more robust. Say you accessed the site with "http://www.joe.com/net/myjoe/content/index.html".
The first iRule would redirect you to "https://www.joe.com/net/myjoe" striping the "/content/index.html" off of the URL (this could be bad or confusing to the users).
The second iRule would do the following.
Redirect from HTTP to HTTPS
Detect the [HTTP::host] - "www.joe.com"
Detect the [HTTP::uri] - "/net/myjoe/content/index.html"
Put it all together and redirect the user: "https://www.joe.com/net/myjoe/content/index.html"