views:

917

answers:

4

ModRewrite can easily handle stripping the www off the front of my domain.
In .htaccess:

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

But with SSL, the certificate check comes before the .htaccess rewrite, causing certificate error.
I would rather not buy an SSL certificate for the www only to redirect it.
Can you offer me a smarter solution? (btw EV Certificates are not available as wildcards)

+2  A: 

You can get certificates with multiple domain names in them. Get one with mydomain.com and www.mydomain.com. I think it's also possible to buy "wildcard" certificates that will match any subdomain, but they cost much more.

John Millikin
Wildcard certificates cost a lot more than a normal cert (I think about 5x from Thawte)
Greg
I think the cheapest is still GoDaddy. Wildcard certs cost $180/year, with them, but you can get a 5-domain cert for $90.
Neall
John Millikin
+1  A: 

Depending on your situation you could look into cacert.

After you are assured by enough people to gain 50 'points', you can create your own server certs, as many as you want.

Normaly you will be 'assured' by someone by meeting with him/her in real life, and showing some kind of ID (drivers license, passport).

For more info read the site, or you pm me.

HuibertGill
+1  A: 

In your situation, two options show promise:
1) When a secure connection is required, link to https://domain.com
Keeping part of your .htaccess redirection

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

will prevent www.domain.com, and hopefully minimise https://www.domain.com
2) As others have suggested, get a separate certificate for https://www.domain.com
startssl.com have free certificates, suitable for a redirection only job like this.

Jolyon
A: 

Many SSL Certificate providers, including DigiCert, GlobalSign, and possibly GoDaddy, will put the www in a certificate for free as a Subject Alternative Name. This means the certificate will work for both paypal.com and www.paypal.com. You can then just forward all traffic from https://www.paypal.com to https://paypal.com.

Robert