Redirect http://mysite.com and http://192.168.89.100 to http://www.mysite.com AND filter on matching URI before redirecting to HTTPS I have one irule (IRULE A)in the http external virtual site http://www.mysite.com If the URI matches one of the three strings shown in IRULE A the client request gets redirected to https://www.mysite.com. It all works fine, no problems. Now I want to resolve another common problem for the same website when the client request is http://mysite.com OR http://192.168.89.100. I have done this for other websites on the F5 that do not need to filter the URI string (as in IRULE A). This was accomplished by using IRULE B. All three matches redirect to HTTPS://www.mysite.com, thereby avoiding the cert error. My thinking is; the HTTP request http://mysite.com and http://192.168.89.100 must be redirected to http://www.mysite.com before the SSL handshake to avoid the cert error AND then redirect to IRULEA or similar logic in the same irule . Only client requests that look like: http://www.mysite.com/checkcenter http://www.mysite.com/thisconnect http://www.mysite.com/mypolicies
should be redirected to: https://www.mysite.com/checkcenter https://www.mysite.com/thisconnect https://www.mysite.com/mypolicies
all other requests will remain http://www.mysite.com/whatever
It would be greatly appreciated if anyone with a skill level far superior to mine can figure this one out and provide me with the syntax to accomplish this. IRULE A when HTTP_REQUEST { switch -regexp [string tolower [HTTP::uri] ] { ^/checkcenter - ^/thisconnect - ^/mypolicies - { HTTP::redirect “https://[HTTP::host][HTTP::uri]” } default { pool web_s_pool} } }
IRULE B
when HTTP_REQUEST {
log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] to [HTTP::host][HTTP::uri]"
switch -glob [string tolower [HTTP::host]] {
"www.*" {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
log local0. "Redirecting www host to https://[HTTP::host][HTTP::uri]"
}
{*[a-z]*} {
HTTP::redirect "https://www.[HTTP::host][HTTP::uri]"
log local0. "Redirecting non-www host to www.[HTTP::host][HTTP::uri]"
}
"192.168.89.100" {
HTTP::redirect "https://www.mysite.com"
log local0. "Redirecting null host to [IP::local_addr][HTTP::uri]"
}
default {
pool AppFW_pool
log local0. "Redirecting to default AppFW_pool"
}
}
}