Forum Discussion
ppphatak_127926
Nimbostratus
Apr 21, 2005substr doesnt work as expected
This is simple rule I wrote. I have a virtual server on port 80 and a proxy for 443, both pointing to this rule.
I was expecting when url is https, it would go to yahoo and when its not https, it would take me to msn.
Problem : In both cases it takes me to msn. First two lines of rules doesnt work at all.
What could be wrong?
if (substr(http_host, 1, 5) == "https") {
redirect to "www.yahoo.com"
}
else {
redirect to "www.msn.com"
}
- There is nothing wrong with your script. The http_host contains the FQDN portion of the URL. Since it contains only the FQDN, it will never match your string compares to the protocol.
- I don't think so as the full URI is not part of the HTTP header or payload. But, after talking with some folks (thanks uRuleY), I realized that you could use the server_port to distinguish whether it's an ssl connection or not. You could do something like the following
if (server_port == 443) { redirect to "www.yahoo.com" } else { redirect to "www.msn.com" }
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