Forum Discussion
katekattar_4936
Nimbostratus
Jun 01, 2009irule SSL Redirect
Hi All,
I have a fairly simple irule to write but can only get half of it correct. I want to send all traffic to a certain URI to HTTPS as well as ensuring all other uri's are not accessed using HTTPS. I have this so far:
when HTTP_REQUEST {
if { [HTTP::uri] equals "/paymentoptionshome/payments" } {
HTTP::redirect https://blahblah.com/paymentoptionshome/payments
}
}
This works but leaves the session in SSL. I need to be able to add something like:
when HTTPS_REQUEST {
if { [HTTPS::uri] !equal "/paymentoptionshome/payments" } {
HTTP::redirect http://[HTTP::host]/[HTTP::uri]
}
}
I do need the first part to be a little more specific, ie. any uri below /paymentoptionshome/payments, perhaps "/paymentoptionshome/payments*" will work.
Any ideas?
Thanks in advance.
Kind Regards
Kate
- Colin_Walker_12Historic F5 AccountSo you want to redirect them if their URI starts with that string, and then force redirect them back if it doesn't?
when HTTP_REQUEST { if { [HTTP::uri] starts_with "/paymentoptionshome/payments" } { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } elseif { (!( [HTTP::uri] starts_with "/paymentoptionshome/payments")) and ([TCP::local_port] == 443) } { HTTP::redirect "http://[HTTP::host][HTTP::uri]" } }
- katekattar_4936
Nimbostratus
Hi Colin, Thanks for your reply. It looks to be exactly what I want. Using your code, it redirects the traffic to HTTPS but it doesn't redirect it back to HTTP. The elseif clause isn't working.
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