Forum Discussion
hooleylist
Jun 15, 2011Cirrostratus
Can you try this instead?
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]"
}
"" {
HTTP::redirect "https://[IP::local_addr][HTTP::uri]"
log local0. "Redirecting null host to [IP::local_addr][HTTP::uri]"
}
default {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
log local0. "Redirecting IP address [HTTP::host] to https://[HTTP::host][HTTP::uri]"
}
}
}
Sample log output for each case:
< HTTP_REQUEST >: 10.1.0.11:54026: GET to www.example.com/test
< HTTP_REQUEST >: Redirecting www host to https://www.example.com/test
< HTTP_REQUEST >: 10.1.0.11:54027: GET to example.com/test
< HTTP_REQUEST >: Redirecting non-www host to www.example.com/test
< HTTP_REQUEST >: 10.1.0.11:54028: GET to /test
< HTTP_REQUEST >: Redirecting null host to 10.1.0.15/test
< HTTP_REQUEST >: 10.1.0.11:54030: GET to 10.1.0.15/test
< HTTP_REQUEST >: Redirecting IP address 10.1.0.15 to https://10.1.0.15/test
Aaron