Can anyone tell me why this iRule wouldn’t work? I have applied this to our VIP-sitename-443 VIP which contains an SSL profile. I need to be able to catch oursite.com on port 443 and append the www, so I applied this iRule to the VIP that contains the SSL certificate, however it is not appending the www.
What response does the client get when you test the rule with a request to https://oursite.com? I’d expect a cert mismatch error because the cert is for www.oursite.com.
In order to avoid a cert mismatch error, you would need a cert which is valid for oursite.com and www.oursite.com. In your original version, you didn’t specify the protocol of https:// in the redirect. Browsers would interpret a redirect location of www.oursite.com (without the protocol) as a local URI which it would append to the previously requested protocol, domain and path (https://oursite.com/www.oursite.com).
With the current rule, you could remove the check of the URI and just redirect to “https://www.oursite.com[HTTP::uri]”. For a requested URI of / the redirect will still be valid.
Redirect users to www.oursite.com before they access oursite.com via HTTPS. You could try to do this on the HTTP VIP. But with a cert which is only valid for www.oursite.com, a direct request to https://oursite.com will trigger an mismatched SSL cert warning.
Change the DNS record for oursite.com or www.oursite.com so they resolve to separate IP addresses. You could then use a separate VIP and SSL cert for oursite.com.
Buy a single cert which is valid for oursite.com and www.oursite.com (sometimes called a Unified Communications Cert). With this, you could accept requests for both hostnames on the same VIP without a mismatched cert warning or redirects.
As Moo suggests, that can’t work to avoid a cert mismatch error. Here are three options to resolve this:
Redirect users to www.oursite.com before they access oursite.com via HTTPS. You could try to do this on the HTTP VIP. But with a cert which is only valid for www.oursite.com, a direct request to https://oursite.com will trigger an mismatched SSL cert warning.
Change the DNS record for oursite.com or www.oursite.com so they resolve to separate IP addresses. You could then use a separate VIP and SSL cert for oursite.com.
Buy a single cert which is valid for oursite.com and www.oursite.com (sometimes called a Unified Communications Cert). With this, you could accept requests for both hostnames on the same VIP without a mismatched cert warning or redirects.