Forum Discussion
hooleylist
Jun 14, 2011Cirrostratus
Good point Michael. If you want to redirect all requests to HTTPS and prepend www. to hostnames without www. you can modify it:
when HTTP_REQUEST {
log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] request to [HTTP::host][HTTP::uri]"
Check if host doesn't start with www and has at least one alpha character
if { not ([string tolower [HTTP::host]] starts_with "www") and [string match {[a-zA-Z]} [HTTP::host]] }{
Redirect to the same host via https with www. prepended
HTTP::redirect "https://www.[HTTP::host][HTTP::uri]"
log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting to https://www.[HTTP::host][HTTP::uri]"
} else {
Redirect to the same host via https
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting to https://[HTTP::host][HTTP::uri]"
}
}
Aaron