Forum Discussion
Kenny_Van_73892
Nimbostratus
Dec 01, 2005redirect and hostheader
Hello all,
I need your help with this irule. I'd like to direct http traffic based on host header but I'd also like to use redirect http traffic to https if someone happens to mistype witho...
Colin_Walker_12
Dec 01, 2005Historic F5 Account
The problem with combining any other rule with a rule that does indescriminant redirecting is that you're almost sure to get yourself in a loop.
So, what you want to do is put an if around that redirect. Something that makes sure they're coming in on port 80 before redirecting them to port 443 and, consequently, doesn't redirect them at all of they're coming in on port 443.
Also, the HTTP::host variable is pre-set, and serves the same function as HTTP::header Host, so I've replaced that below as well.
Try this:
when HTTP_REQUEST {
if{ [TCP::local_port] == 80 } {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
return
}
if { [HTTP::host] contains "test1" } {
pool Test1
} elseif { [HTTP::host] contains "test2" } {
pool Test2
} else {
discard
}
}HTH,
-Colin
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
