Forum Discussion
If list of uri requested..Redirect to https and select pool
Hi All,
I have list of uri's which are around 100 plus (example:en-*) . whenever there are request with this uri, its should get redirected to https and pool should be selected. Currently using below irule which only does pool selection but no redirection.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/en/*" -
"/coxtnt/*" -
"/asts/*" -
"/etc/*" -
"/pr/web/*" -
"/libs/*" -
"/ptc/*" -
"/en-/" {
pool com-new-en-pool
}
default {
pool com-http } } }
need assistance in irule
- CharlesCS
Cirrus
If you intend to redirect these requests to an HTTPS virtual server, then you do not need to select a pool here. The pool selection should take place in the targeted virtual server instead.
- Snl
Cirrostratus
Try below options
Code- when HTTP_REQUEST { switch -glob [string tolower [HTTP::path]] { "/in/*" { HTTP::redirect "http://New_http_URL_1" } "/us/*" { HTTP::redirect "http://New_http_URL_2" } "/uk/*" { HTTP::redirect "http://New_http_URL_3" } "/sg/*" { HTTP::redirect "http://New_http_URL_4" } } }
option 2
Code when HTTP_REQUEST { log local0. "uri info: [HTTP::uri]" switch -glob [string tolower [HTTP::uri]] { "/corp*" { pool corp } "/corp/" { pool corp } "/MBSP/" { pool mbsp } default { pool nbqpool } log local0. "pool info: [LB::server pool]" } }
- Hectorm
Nimbostratus
you will need two VIPS one VIP for port 80 or HTTP and another VIP for the HTTPS. So in the VIP for port 80 you can put a very similar rule as the one for the pool. something like this when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] { "/en/*" { set VRedirection "true"} "/coxtnt/*" { set VRedirection "true"} "/asts/*" { set VRedirection "true"} "/etc/*" { set VRedirection "true"} "/pr/web/*" { set VRedirection "true"} "/libs/*" { set VRedirection "true"} "/ptc/*" { set VRedirection "true"} "/en-/" { set VRedirection "true"} default { set Vredirection "false" } } if { $Vredirection equals "true" } then { HTTP::redirect "https://[HTTP::host][HTTP::uri]"}
}
This rule will only redirects specifics uri. Then on the HTTPS rule you can do the pool selection just like you have done
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