1

How can I redirect from https://mysite.com to https://www.mysite.com? The SSL certificate is bought for www.mysite.com and shows a warning if accessed without www.

1 Answer 1

1

It will be too late. Users will have already seen the error message and had to accept it by the time the redirect happens unless you get another certificate. The previous answer has that problem.

Ignoring that, you can create a named based virtual host on port 443, set up ssl on that, and then have it rewrite. Note that instead of using your existing certificate (which will generate an error) you can have a cheap, valid certificate under mysite.com on that virtual host so that you don't get an error prior to the redirect.

NameVirtualHost *:443
<VirtualHost *:443>
  ServerName myname.com
  SSLCertificateFile /etc/ssl/apache2/server.crt
  SSLCertificateKeyFile /etc/ssl/apache2/server.key
  SSLEngine on
  RewriteEngine on
  RewriteRule ^/(.*)  https://www.mysite.com%{REQUEST_URI}      [L,R]
</VirtualHost>
4
  • So you are saying without getting one for no www there's no way to redirect without the warning, right?
    – Francisc
    May 19, 2011 at 21:37
  • 1
    If they type https : //mysite.com, no. On the plus side, you don't need ultimate double plus premium certificates for mysite.com. Whatever the cheapest you can find (some are free) which will get the user redirected to the real website which can have whatever level of certification necessary is fine. You might want to investigate the very expensive wildcard certificates, but I don't think they allow mysite.com and www.mysite.com, just www.mysite.com and support.mysite.com and foo.mysite.com, etc. May 19, 2011 at 21:46
  • 1
    Google pointed me to (randomly, never seen them before) digicert which claims they can support a single wildcard cert for the top level and the subdomains. Is this really the same cert or just multiple certs in the same container? Check it out. Please accept if you like the answer. May 19, 2011 at 21:49
  • I already accepted it. I'll take a look, thanks again.
    – Francisc
    May 19, 2011 at 21:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .