redirect non www to https+www

Hello to all, Im trying to get ahold of irule to redirect any traffic coming to my website example.com to https://www.example.com[uri]

I’ve been searching over google for couple of hours now.

Thanks in advance

Hi Chenco,

You can try this below redirection irule.

when HTTP_REQUEST {
if {[string tolower [HTTP::host]] eq "example.com"}
HTTP::respond 301 Location "https://www.[HTTP::host][HTTP::uri]"   
}


Let me know if any issue.
Thanks & Regards,
Habib Khan

Hi,

You can default system irule for http to https redirection. Irule name is _sys_https_redirect. when HTTP_REQUEST { HTTP::redirect https://[getfield [HTTP::host] “:” 1][HTTP::uri] }

or you can use custom irule as mentioned below.

when HTTP_REQUEST {

if {[HTTP::host] equals “test.com”} {HTTP::respond 301 “Location” “https://test.com[HTTP::uri]”} }