Forum Discussion
scottl_82413
Nimbostratus
Feb 07, 2008Don't redirect to SSL if URI exists
I'm trying to create an irule that will redirect:
http://www.mysite.com to https://www.mysite.com
however, if someone goes to http://www.mysite.com/training
I don't want it to redirect.
I've tried several irules to do this, as well as http class profiles, but can't seem to accomplish it.
Any ideas? I'm open to either an irule or http class profile
- hoolio
Cirrostratus
Hi,when HTTP_REQUEST { Check if requested path isn't /training if {not ([HTTP::path] eq /training)}{ Redirect request to the same host/uri, but via HTTPS HTTP::redirect https://[HTTP::host][HTTP::uri] } }
- scottl_82413
Nimbostratus
Thanks for the reply...still not working...it still redirects to https://www.mysite.com/training - hoolio
Cirrostratus
Sorry...typing faster than thinking. You do need quotes for the comparison.when HTTP_REQUEST { log local0. "Client [IP::client_addr] requested [HTTP::host][HTTP::uri]" Check if requested path isn't /training if {not ([HTTP::path] eq "/training")}{ log local0. "Redirecting client [IP::client_addr] from [HTTP::path] to [HTTP::host][HTTP::uri]" Redirect request to the same host/uri, but via HTTPS HTTP::redirect https://[HTTP::host][HTTP::uri] } }
- scottl_82413
Nimbostratus
Here's what the logs show: - hoolio
Cirrostratus
It sounds like you want to allow HTTP access to any URI starting with /training, not just equal to /training. Can you try this version?when HTTP_REQUEST { log local0. "Client [IP::client_addr] requested [HTTP::host][HTTP::uri]" Check if requested path doesn't start with /training if {not ([HTTP::path] starts_with "/training")}{ log local0. "Redirecting client [IP::client_addr] from [HTTP::path] to [HTTP::host][HTTP::uri]" Redirect request to the same host/uri, but via HTTPS HTTP::redirect https://[HTTP::host][HTTP::uri] } }
- hoolio
Cirrostratus
Third time was a charm. Glad it's working for you. - ask_me_anytime_
Nimbostratus
hi, - kykong_107132
Nimbostratus
Hi Sakalon, - ask_me_anytime_
Nimbostratus
Hi KY,
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