Forum Discussion
JonasD_46068
Nimbostratus
Mar 07, 2007iRule for HTTPS & www
I have 2 iRules:
when HTTP_REQUEST { HTTP::redirect https://[HTTP::host][HTTP::uri] }
and
when HTTP_REQUEST { if {[HTTP::host] equals "testdomain.net"} {HTTP::redirect "https://www.testdomain.net[HTTP::uri]" } }
When both rules are applied they obviously cancel each other out. When I only have the 2nd rule applied obviously the redirection doesn't work. What I am trying to do is 2 things in 1 irule (if it needs to be more than 1 rule that is fine too). I want to redirect connections that go to http to https. I also want to redirect requests to testdomain.net without the www to https also. How can I do this?
- This should do it nicely (if a little unelegantly):
when HTTP_REQUEST { set userhost [HTTP::host] if { $userhost == "testdomain.net" } { set userhost "www.[HTTP::host]" } HTTP::redirect https://$userhost[HTTP::uri] }
- JonasD_46068
Nimbostratus
Thanks! - JonasD_46068
Nimbostratus
Here's the original rule I typed in that you gave me: - Mike_Graston_10
Nimbostratus
I actually implemented this rule and it worked like a champ. I cut and pasted it right from the text above and changed only the doamin name.The syntax errors are something that always drives me nuts so I will paste it in as I have it: - JonasD_46068
Nimbostratus
You replied before I could. You are CORRECT, it was all syntax...i typed it in EXACTLY as you had it line breaks and all and it worked PERFECTLY. Thanks. I do a lot of work with F5s now and these iRules are fantastic.
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