Forum Discussion
Lon_bale_55412
Nimbostratus
Nov 06, 2009URI redirection https to an external http URL
Currently we are trying to redirect a to an external URL from one that sits behind the F5 with no luck.
The user hits the site via https://myserver/spaces and we are trying to redirect ...
hoolio
Cirrostratus
Nov 09, 2009You could replace the HTTP profile functionality for rewriting redirects with an iRule that inspects the Location header in redirects and only rewrites to https:// for your specific scenarios. If you have a lot of URIs to check you could add them to a datagroup. In this example, I've used a class named locations_to_preserve_class
when HTTP_RESPONSE {
Check if response is a redirect
if {[HTTP::is_redirect]}{
Save the Location header value to lowercase
set location [string tolower [HTTP::header Location]]
Check if the Location header value starts with http:// and is not one to preserve as http://
if {$location starts_with "http://" \
and not ([matchclass $location starts_with $::locations_to_preserve_class])}{
Replace http:// with https:// in the Location header
HTTP::header replace Location [string map "http:// https://" $location]
}
}
}
Aaron
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
