Forum Discussion
Redirect with multiple conditions
I am doing a HTTPS redirect for all of the sites at my domain. I need to make an exclusion for 2 sites so that they can be access via HTTP.
For example, any traffic to http://www.abc.com is redirected to https://www.abc.com. I would like requests to http://www.abc.com/site1 and http://www.abc.com/site2 to be allowed to go to the HTTP site while all other traffic is redirected to HTTPS.
I've attempted to do this with the following iRule, but it is not working. Any assistance would be greatly apreciated.
Thanks!
when HTTP_REQUEST {
if { not ([string tolower [HTTP::uri]] starts_with "/site1") } {
HTTP::respond 301 Location "https://www.abc.com[HTTP::uri]"
}
elseif { not ([string tolower [HTTP::uri]] starts_with "/site2") } {
HTTP::respond 301 Location "https://www.abc.com[HTTP::uri]"
}
}
- What_Lies_Bene1
Cirrostratus
Firstly, remove the nots! I think perhaps also enclose Location in quotes so it's "Location". Let me know how you get on. - What_Lies_Bene1
Cirrostratus
So, like this, I don't think the curved brackets are needed either btw;when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/site1" } { HTTP::respond 301 Location "https://www.abc.com[HTTP::uri]" } elseif { [string tolower [HTTP::uri]] starts_with "/site2" } { HTTP::respond 301 Location "https://www.abc.com[HTTP::uri]" } }
- Stuart_Feathers
Nimbostratus
I have also tried the following iRule which doesn't seem to work either. - Stuart_Feathers
Nimbostratus
Thank you for the reply What Lies Beneath. - What_Lies_Bene1
Cirrostratus
You're welcome!
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