Forum Discussion
Another http redirect question
I've scoured devcentral and google and haven't found my answer. I'm trying to redirect http based on header. A CNAME gets traffic to our VIP as well as straight http that needs to be redirected to https. http to https iRule has been in place and working for a long time I'm just trying to add this other header. Is this possible?
when HTTP_REQUEST {
if { [HTTP::host] contains "mail.domain.com"} {
HTTP::redirect https://[HTTP::host][HTTP::uri]
if { [HTTP::host] contains "exchange.mail.com"} {
HTTP::redirect http://www.domain.com/page.html[HTTP::uri]} } }
7 Replies
- Kevin_Stewart
Employee
The first condition does more or less what the default http-to-https code does. Are you using this iRule in addition to another iRule?
when HTTP_REQUEST { switch [string tolower [HTTP::host]] { "mail.domain.com" { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } "exchange.mail.com" { HTTP::redirect "http://www.domain.com/page.html[HTTP::uri]" } } }Though I might add that the URI "/page.html[HTTP::uri]" doesn't really make sense. If the request URI was "/foo", then you'd redirecting them to "/page.html/foo".
- kraigk_52257
Nimbostratus
Kevin,
That worked like a charm. Can you get me a solution faster next time? :-)
thanks much.
- kraigk_52257
Nimbostratus
A question just occurred to me. Not sure if this is possible.. is there a way to redirect this whether or it comes in http or https? Add a third condition?
"exchange.mail.com" { HTTP::redirect "http://www.domain.com/page.html[HTTP::uri]" } } } - Kevin_Stewart
Employee
Not sure I understand. If this is on the HTTP VIP, it'll come in HTTP://, likewise for the HTTPS VIP.
- kraigk_52257
Nimbostratus
So the above you provided works great provided the exchange.domain.com is browsed via http://exchange.domain.com. If https://exchange.domain.com it doesn't redirect.
- Kevin_Stewart
Employee
Can I assume you have separate HTTP and HTTPS VIPS? If so, put that section of code in an iRule on the HTTPS VIP.
- kraigk_52257
Nimbostratus
Duhh. Thanks for the obvious solution.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
