0

How do I redirect visitors from https://domain.net to https://www.domain.net ? Using an A record or some other DNS settings?

I am asking because I made the mistake of purchasing an SSL certificate for www.domain.net...

Thanks for any ideas!

3
  • Can you contact the issuer of the SSL cert and have them change it to be for *.domain.net?
    – nhinkle
    Jul 5, 2010 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, 2010 at 1:51
  • 1
    Have you considered creating a site not running SSL (ie standard http over port 80) with domain.net and add a redirect rule (using either IIS URL Rewrite or mod_rewrite to the https version in www.domain.net)? This way at least your customers can type just the domain.net and get redirected and no SSL warnings or issues. Jul 6, 2010 at 2:56

7 Answers 7

5

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

1
  • +1, you need to configure the web server to do this redirection. It cannot be done purely in DNS.
    – David Z
    Jul 5, 2010 at 20:35
2

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]
2
  • 1
    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). Jul 6, 2010 at 0:02
  • Thanks. I missed the https in the question. Your addition should work. Jul 6, 2010 at 7:22
2

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 www.domain.net, 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 domain.net, 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 www.domain.net and domain.net. 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 www.domain.com and domain.com (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 domain.net, 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 domain.net, 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).

1

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 http://redirect.200please.com

Remember, never use CNAME to redirect

0

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

Try this:

http://www.domainredirect.com/

2
  • I was rather looking for something related to A records/DNS...
    – Anonymous
    Jul 5, 2010 at 19:35
  • Hmm, not too sure what you mean. Here's another article I found. ask-leo.com/…
    – BioXhazard
    Jul 5, 2010 at 19:56
0

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

0

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: https://yoursite.com/'.$_SERVER["REQUEST_URI"]); exit; }

You must log in to answer this question.