Forum Discussion
Steve_Manuel_11
Nimbostratus
Oct 06, 2006http/https redirect
Hello everyone;
I'm trying to do a simple http https redirect for a VSA.
Before
http://cms-d3.tmi.telus.com
looking to see
https://cms-d3.tmi.telus.co...
Deb_Allen_18
Oct 06, 2006Historic F5 Account
Hi Steve -
You didn't really indicate if you were encountering dificulty, or what kind of answer you were hoping for, or what exactly the logic is you're trying to enforce, but I can see a couple of things you might want to clean up.
1) You are setting the variable "uri" and never using it. Since the function [HTTP::uri] is cached, you could reduce the iRule overhead by not setting the variable and continuing to use [HTTP::uri]. However, you might want to consider a case-insensitive comparison, setting the variable to equal the all-lower-case version of the URI, and then refering to the variable instead of the function:
set uri [string tolower [HTTP::uri]]
...
if {$uri starts with "/da/"}{
...2) A couple of things make me wonder if you are expecting to see the protocol scheme & hostname as part of the output of [HTTP::uri]. URI means the part /after/ the hostname, including the leading slash. For example, in "http://host.domain.com/uri", the URI is "/uri", and the hostname is "host.domain.com". [HTTP::host] is the command to use for comparison with the hostname in the request.3) You could use a class or a switch construct to manage traffic for different URIs. Since the destination is the same, I recommend a class (data group list) containgin the URI's for which you will switch to the CMS pool. It also looks like you could extract just the first directory and use that value for most of your conditions.
I'm not sure what you were trying to catch with the second to last elseif, but perhaps something more like this iRule:
when HTTP_REQUEST {
set uri_first [getfield [string tolower [HTTP::uri]] "/" 2]
if {[matchclass $uri_first equals $::CMS_uris]}{
pool D3_INT1_CMS
} elseif { not ( $uri_first contains ".") and not ([HTTP::uri] contains "${uri_first}/") } {
HTTP::redirect "https://[HTTP::host]/${target}/"
} elseif {[string tolower [HTTP::host]] starts_with "cms"} {
HTTP::redirect "https://cms-d3.tmi.telus.com"
} else {
pool D3_INT1_CONTENT
}
}which would use the following class list:class CMS_uris {
"da"
"webtop"
"woh"
"wp"
}HTH
/deb
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
