Forum Discussion
Ahmad_03_151082
Nimbostratus
Mar 24, 2015Http to Https except specific URLs
Dears,
I am facing an issue with iRules i have created below iRule
when HTTP_REQUEST {
HTTP::redirect https://[getfield [HTTP::host] ":"][HTTP::uri]
...
Hannes_Rapp_162
Nacreous
Mar 25, 2015Good luck 😉
when HTTP_REQUEST {
switch [string tolower [HTTP::host][HTTP::path]] {
"abc.com/xyz" -
"abc.com/example1" -
"abc.com/example2" {
return
do nothing
}
default {
HTTP::respond 302 location "https://[HTTP::host][HTTP::uri]"
event disable
prevent a possibility of multiple redirect invocations (not needed, if it's your only iRule attached to the VS)
TCP::close
remove the TCP connection record from the connections table. Needed for some browsers, because if the connections record remains, the same redirect will not work the second time in a different tab.
}
}
}
Hannes_Rapp_162
Nacreous
Mar 25, 2015In this case you would want to use the priority function.
Add the code "priority 10" (without quotes) to the beginning of the iRule (1st Line). This will ensure the HTTPS redirect iRule is processed before your secondary iRule. Might want to share your other iRule? We should make sure no important functionality loss will occur.
Edit:
- Also please share your exact request page when testing (e.g. http://abc.com/xyz)
- Does the back-end server (pool member) serve more than one vHost via the same VS? I need to know if "abc.com" is the only host served, or are there more?
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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