Forum Discussion
kaviraj_Daboo_1
Nimbostratus
Jul 04, 2013HTTP-HTTPS redirection
Hello,
Kevin_Stewart
Employee
Jul 04, 2013With the irule when my client goes to www.x.fr/y/z it remains in HTTP thats OK. When accessing www.x.fr/y he is redirected to HTTPS thats OK but when going to www.x.fr/y/z it remains in HTTP whereas it should have been redirected to HTTPS.
This is a little confusing. According to your original statements, "www.x.fr/y/z" should be HTTP. Did you mean that from "www.x.fr/y/" to "www.x.fr/y/z" it should redirect FROM HTTPS to HTTP?
If the above is true, then you need to build your logic from MOST explicit to LEAST explicit. Here's a switch structure that, I think, does essentially what you're asking for.
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "test.domain.com" } {
switch -glob [string tolower [HTTP::uri]] {
"/y/z*" {
if { [TCP::local_port] ne "80" } { HTTP::redirect "http://[HTTP::host][HTTP::uri]" }
}
"/y/*" {
if { [TCP::local_port] ne "443" } { HTTP::redirect "https://[HTTP::host][HTTP::uri]" }
}
"/y*" {
if { [TCP::local_port] ne "443" } { HTTP::redirect "https://[HTTP::host][HTTP::uri]" }
}
"/*" {
if { [TCP::local_port] ne "80" } { HTTP::redirect "http://[HTTP::host][HTTP::uri]" }
}
default { drop }
}
}
}
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