Forum Discussion
Assistance with multiple instance i-Rule using multiple http to https redirect
Hi Shlairshe,
if I got it right, you want to redirect to https only for exact match and in case of path starting with a specific pattern a specific pool should be selected.
The following one should meet your requirements after adjusting the path and pool specification:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::path]] {
"/path1" { HTTP::redirect https://[getfield [HTTP::host ] ":" 1][HTTP::uri]
"/path1/*" { pool }
"/path2" { HTTP::redirect https://[getfield [HTTP::host ] ":" 1][HTTP::uri]
"/path2/*" { pool }
"/path3" { HTTP::redirect https://[getfield [HTTP::host ] ":" 1][HTTP::uri]
"/path3/*" { pool }
}
}
The "-glob" allows using wildcards and exact match versus the requested path. Exact matches will be redirected to https. Matches equivalent to "starts_with" ("/path/*") will simply forward to the resource pool. Please notice also the difference between path and uri (containing the path and the query of the requested url. Perhaps you want to change the "switch" command to "switch -glob [string tolower [HTTP::uri]]" in case there is a query following the path. But in this case we would probably need to modify the whole iRule.
It will probably be required to use a OneConnect profile on your virtual server. The syntax "use pool " is deprecated. Please code "pool ".
Thanks, Stephan
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