Forum Discussion
Tony_Kitzky_936
Aug 24, 2013Nimbostratus
How best to accomplish HTTP redirection for specific URLs?
I am trying to create a site where some URLs are not redirected to HTTPS but all other URLs do get redirected. I do not know what is the best method to accomplish this. I want the ability to easily a...
Kevin_Stewart
Aug 24, 2013Employee
I'd go with the data group method. It's by far the easiest to manage and requires no subsequent changes to the iRule. Example.
Data group - string-based (ex. my_uri_dg)
"/uri1"
"/uri2"
"/uri3"
"/uri4"
iRule:
when HTTP_REQUEST {
if { not ( [class match [string tolower [HTTP::uri]] starts_with my_uri_dg] ) } {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
}
}
So as long as the requested URI pattern (starts_with) is in the data group, the request will pass through. Otherwise, for everything else, it gets redirected. It doesn't appear that the host name changes, so you shouldn't have to evaluate that. Also note that we're just looking for data the group key, so the corresponding values can be empty.
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