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 without "s".
when HTTP_REQUEST {
HTTP::redirect https://[HTTP::host]
if { [HTTP::header Host] contains "test1" } {
pool Test1
}
elseif {[HTTP::header Host] contains "test2"} {
pool Test2
}
else { discard }
}
When I tested either single irule (redirect and hostheader), then everything worked just fine but when I combined them into a single irule as showed, then the http traffic got freaked out and didn't know where to go. Did I do something wrong here? Thanks all.
- Colin_Walker_12Historic F5 AccountThe 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.
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 } }
- Kenny_Van_73892
Nimbostratus
Thanks Colin. - Colin_Walker_12Historic F5 AccountWhen you say the redirect didn't work...what do you mean? How did it behave?
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