How to redirect non www to www

Hi community

i have a virtual server (port 443) and i would like to create a iRule that redirects from non www to www

After enabling the iRule the Browser (Firefox, Chrome) says: PR_CONNECT_RESET_ERROR.

i have tried with:

when HTTP_REQUEST {
   if {  [HTTP::host] ne "www.mydomain.com" } {
      HTTP::respond 301 Location "https:/www.mydomain.com"
   }


}

Hi,

Do you have any client SSL attached to the virtual server?

It sounds like you are not decrypting packets before read or write that.

Regards

hi cjunior,

yes, we have a client ssl profile attached to the VS. we are doing SSL offlaoding.

regards

OK, sorry the inconvenience.

So if you remove your iRule it back to works? Didi you catch some execution error on LTM log?

I don’t think this single slash typo “https:/www” affect that, but :confused:

Maybe you can try running command line on bash to know if the problem is on your browser.

10.10.10.10 = replace with your VS IP address

Did you get the HTTP 301 and new location running this?

curl -kv --resolve other.mydomain.com:443:10.10.10.10 https://other.mydomain.com

Did you get any issue running this?

curl -v --resolve www.mydomain.com:443:10.10.10.10 https://www.mydomain.com

Regards

hi

we will add some logs in the Irule for better debugging. We think there is a conflict between the redirect on the LTM and a redirect locally on the web server. We are now investigating with the developers. thx