Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I redirect visitors from to ? Using an A record or some other DNS settings?

I am asking because I made the mistake of purchasing an SSL certificate for

Thanks for any ideas!

share|improve this question

migrated from Jul 5 '10 at 21:31

This question came from our site for computer enthusiasts and power users.

Can you contact the issuer of the SSL cert and have them change it to be for * – nhinkle Jul 5 '10 at 20:31
You can not do a redirect (which is a part of HTTP) with a totally different protocol (like DNS). – Chris S Jul 6 '10 at 1:51
Have you considered creating a site not running SSL (ie standard http over port 80) with and add a redirect rule (using either IIS URL Rewrite or mod_rewrite to the https version in This way at least your customers can type just the and get redirected and no SSL warnings or issues. – Carlos Aguilar Mares Jul 6 '10 at 2:56

Configure your server to issue an HTTP 301 response to map the one to the other, eg using Redirect with Apache.

share|improve this answer
+1, you need to configure the web server to do this redirection. It cannot be done purely in DNS. – David Z Jul 5 '10 at 20:35

You'll need to set up your webserver to send a redirect to the browser. Here's how I do this in Apache.

Point both the DNS records to the same IP address (for example with a CNAME alias), and place the below code in a virtualhost that listens on this address. You'll also need to have mod_rewrite enabled.

# Do an external redirect:
# Places www in front of the domain, but only if there's no www or other subdomain yet.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^.*\..*\..*$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}$1 [R=301,L]
share|improve this answer
You need to redirect to https://... in the RewriteRule. You might also want to add RewriteCond %{HTTPS} =on to avoid redirecting plain http traffic to https (unless that's what you want). – Gordon Davisson Jul 6 '10 at 0:02
Thanks. I missed the https in the question. Your addition should work. – Martijn Heemels Jul 6 '10 at 7:22

As andrushka and Martijn Heemels said, you need to configure a web server to redirect clients to the www. address. But since this is https we're talking about, it's more complicated than that. When the browser client opens an SSL connection to to the server it thinks of as, it expects the server to respond with a certificate that's valid for that domain before it sends the HTTP request (and thus gets a redirect in response). If your server just has a cert for, you'll get a certificate warning. There are several ways to deal with this:

1- Live with it, and configure the server to redirect clients to the correct domain (after they get the cert warning). Not great for security, as you're training your users to trust any random impostor site that pretends to be you...

2- Don't bother with the redirect, just serve the same content under both and Your users are going to get the same warning either way, so there's not much point in redirecting (unless you want it for some other reason, like URL consistency).

3- Get a dual-domain cert that's valid for both and (one as the cert's Subject, the other in a Subject Alternative Name extension), and use it with either of the first two approaches. I haven't tried them, but I think StartSSL's free certs include this capability.

4- Get a separate cert for, and run a second server (or a virtual server on a different IP address) to handle the redirects. It has to be on a different IP address so it knows which certificate to use before it sees the client's HTTP request.

5- Get a separate cert for, run a second virtual server on the same IP address using server software new enough to support the Server Name Indication extension to SSL/TLS (i.e. Apache 2.2.12 or later), and hope that the client's browser is also new enough (some will be, some won't).

share|improve this answer

DNS servers can not perform HTTP redirect. You should use a webserver to do the 301 redirection. All modern servers like Apache / lighttpd supports HTTP redirection. You can also use third party tools like

Remember, never use CNAME to redirect

share|improve this answer

I believe there are ways to redirect domains using a free webservice or developing your own tool.

Try this:

share|improve this answer
I was rather looking for something related to A records/DNS... – Anonymous Jul 5 '10 at 19:35
Hmm, not too sure what you mean. Here's another article I found.… – BioXhazard Jul 5 '10 at 19:56

Why not just talked to the SSL seller and ask to rename the SSL certificate you have purchased?

share|improve this answer

If you aren't comfortable with messing with your web server's configuration files, many scripting languages can also issue the HTTP redirect. Here's a PHP example:

if ($_SERVER['HTTPS']!="on") { header('Location:'.$_SERVER["REQUEST_URI"]); exit; }

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.