Forum Discussion
Jules_Green_252
Nimbostratus
Mar 18, 2016I want to combine 3 iRules that are all redirects without "too many redirects" error
First iRule on port 80 VIP *forces ssl unless specific uri which will remain on 80":
when HTTP_REQUEST {
if { ! ( [string tolower [HTTP::uri]] starts_with "/investors" ) } {
HTTP::redir...
Greg_Labelle
Nimbostratus
Mar 18, 2016Here is an example of how I would run through this issue:
when CLIENT_ACCEPTED {
switch [TCP::local_port] {
"443" {
set proto "https"
}
default {
set proto "http"
}
}
}
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
"/investors*" {
if { ($proto equals "https") } {
HTTP::redirect "http://[HTTP::host][HTTP::uri]"
}
}
default {
if { ($proto equals "http") } {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
} elseif { ([HTTP::host] equals "domain.com") } {
HTTP::redirect "$proto://www.domain.com[HTTP::uri]"
}
}
}
}
The basic concept is - you can have multiple HTTP::redirect commands in a single iRule, but no two can be logically reachable at the same time. So long as the logic only allows one to execute in any given request, you should be clear. Switch and elseif's eliminate the potential for multiple executions.
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