Forum Discussion
How best to accomplish HTTP redirection for specific URLs?
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.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
