Forum Discussion

AP_129594's avatar
AP_129594
Icon for Nimbostratus rankNimbostratus
Oct 08, 2013

Redirect https from non www to www host name

SO I found the iRule to redirect from http://mysite.com to http://www.mysite.com, but if users going directly to HTTPS://mysite.com, they get this page can't be displayed or "ERROR_INTERNET_CONNECTION_RESET". Any suggestion for an iRule to fix this? Here is the irule that currently I use:

 

when HTTP_REQUEST { if { [HTTP::host] eq "mysite.com"}{ HTTP::redirect "http://www.mysite[HTTP::uri]" }

 

7 Replies

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    https://devcentral.f5.com/questions/ssl-cert-warning-with-irule-https-to-http

     

  • Did you research what does " "ERROR_INTERNET_CONNECTION_RESET" mean? Why do you think you need an iRule to fix it?
  • Thanks Jie, We have a SAN cert with alternate name without www. What should I do next? AP

     

  • This error is not usually indicative of SSL issues. Are you getting SSL warnings BEFORE this error, or does it just go directly to this? So based on the iRule that you specified:

    when HTTP_REQUEST { 
        if { [HTTP::host] eq "mysite.com" } { 
            HTTP::redirect "http://www.mysite[HTTP::uri]" 
        }
    }
    

    You're telling the client to go to an HTTP (port 80) URL. Did you mean HTTPS? Did you mean to leave off the ".com" in the redirect URL? Does "www.mysite.com" actually resolve to something in DNS?

  • It was my typo with the missing .com. This irule is currently worked for http://mysite.com to http://www.mysite.com. I need to get https://mysite.com redirect to https://www.mysite.com and the certificate is a SAN cert with both DNS= mysite.com and www.mysite.com.