Forum Discussion
cquick11_115408
Nimbostratus
Mar 22, 2014http redirect to https based on http::uri
I am trying to set up redirection from http to https, and vice versa, based on uris.
examples: /login.aspx /dashboard.aspx. If someone went to login.aspx and it should go to https, then if someone cl...
giltjr
Nimbostratus
Mar 24, 2014Corrected code Post
when CLIENT_ACCEPTED {
Check for SSL
if {[TCP::local_port] eq 443 } {set SSL 1} else {set SSL 0}
}
when HTTP_REQUEST {
if {[HTTP::cookie exists "SecureStat"] } {
set SecureStat [HTTP::cookie "SecureStat"]
if {!$SSL } {
if {[class match [HTTP::uri] ends_with stage_ssl] } {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
}
} elseif {!$SecureStat and not [class match [HTTP::uri] starts_with stage_ssl] } {
HTTP::redirect "http://[HTTP::host][HTTP::uri]"
}
} else {
set cookie [format "%s=%s; path=/; domain=$HostName" "SecureStat" $SSL]
if {!$SSL } {
if {[class match [HTTP::uri] ends_with stage_ssl] } {
HTTP::respond 302 Location "https://[HTTP::host][HTTP::uri]" "Set-Cookie" $cookie ; return
}
} elseif {not [class match [HTTP::uri] starts_with stage_ssl] } {
HTTP::respond 302 Location "http://[HTTP::host][HTTP::uri]" "Set-Cookie" $cookie ; return
}
}
}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