Forum Discussion
Todd_94419
Sep 13, 2011Nimbostratus
HTTP to HTTPS Redirect based on URI
It would appear that there have been several posts pretaining to this type of question but I have been unable to find something that fits exactly, and I am not able to get it to work.
Trying to redirect from my HTTP VIP to HTTPS VIP only if certain link is clicked.
URI for the link is www.company.com/abc
At that point I would want the link to be redirected to the HTTPS version of that page. This is what I have tried with no luck.
when HTTP_REQUEST {
if {[HTTP::uri] eq "/abc"} {
HTTP::redirect "https://www.company.com/abc[HTTP::uri]"
}
}
I've tried a 301 redirect as well thinking that might work...
As you can tell I'm pretty new to F5 and iRules. Sorry if I've overcomplicated things... any help is appreciated.
Thanks
- Brian_69413NimbostratusYou could do this:
when HTTP_REQUEST { if { [HTTP::uri] eq "/abc"}{ HTTP::redirect "https://[HTTP::host][HTTP::uri]" } }
- Michael_YatesNimbostratusI would suggest changing your comparison from equals to starts_with or contains.
- Todd_94419NimbostratusThis worked! Thanks everyone, I appreciate the help.
- Michael_YatesNimbostratusThe HTTP::uri is case sensitive depending on which operating system you are using (Apache vs. IIS, and probably a few others).
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