6

My DNS setup is rather simple: a CNAME for www, default (registrar's) nameservers for the root.

Now I want to redirect from the root domain to www, which I thought would be a simple task, but it's not working.

I've followed every guide out there on how to change the htaccess file and my registrar is even offering a simple setting to do this as well, but no result. When I go to the root of my domain in a browser it instantly says:

mydomain.com's server DNS address could not be found.

What's the right course of action here? Should I add a server alias? A domain alias? Should I add some records to my DNS settings? I'm out of ideas.

Note: I do not have a static IP address for my server. Rather, I need to direct requests to my server using a CNAME record.

10
  • And your www subdomain works OK? What does your CNAME record say? How long has it been since the DNS has been configured? If you are within the first 48 hours then the domain could still be propagating around the world's DNS servers.
    – DocRoot
    Jul 15, 2016 at 15:56
  • @DocRoot Yeah, works perfectly. My CNAME says www. Configured it a week ago.
    – Yeats
    Jul 15, 2016 at 18:07
  • "My CNAME says www." - I'm not sure that I follow? It seems you already have an answer to your problem, but I'm curious as to what your CNAME record actually points to (the value of the CNAME record; "www." is effectively the name)? (A CNAME record is simply an alias that points to the canonical domain.) Ordinarily a CNAME record for www points to the bare domain eg. example.com (the canonical domain) for which an A record points to the IP address. A CNAME record by itself is not "normally" sufficient; but you say this works OK??
    – DocRoot
    Jul 15, 2016 at 21:36
  • 1
    @DocRoot PaaS provider (Galaxy for Meteor).
    – Yeats
    Jul 15, 2016 at 21:39
  • Ah yes, I see your problem now. As mentioned in comments below, you will need another server (or service) to which to point an A record to (for the "bare" domain) so you can manage the HTTP redirection. There is additional information on the Meteor.com website: Redirecting the root domain
    – DocRoot
    Jul 15, 2016 at 22:26

1 Answer 1

8

You need an A record for your domain root, pointing to the IP address of your server.

Only once you have that in place (thus directing requests for example.com to your server) will your .htaccess rules take effect.


Since your server does not have a static IP address, you will need to find out if your DNS provider supports ALIAS or ANAME records. These allow you to have CNAME-like functionality at the zone apex. If your provider does not support these records types, you should be able to move to a provider that does support them without significant effort.

18
  • 1
    I have a CNAME. My server doesn't have a static IP address.
    – Yeats
    Jul 15, 2016 at 19:37
  • That would be helpful information to include in your question, as it changes things significantly.
    – EEAA
    Jul 15, 2016 at 19:38
  • 1
    Yes, I'm saying that this is impossible. You cannot have a CNAME at your domain apex (example.com). Also, redirects are a function of HTTP, not DNS. You need both pieces in place to do what you want - you need DNS records that direct clients to the correct server, and then on the server, you need an HTTP redirect to redirect requests from example.com to www.example.com.
    – EEAA
    Jul 15, 2016 at 19:42
  • 1
    Sure, that would be fine. Then you're managing another server, though, and if that server goes down, requests to example.com will fail.
    – EEAA
    Jul 15, 2016 at 19:44
  • 1
    " Why do I need an A record pointing somewhere before the htaccess rules take effect?" Because how else will request from your clients reach the server that is hosting your apache/htaccess? Requests need to get there somehow, and that somehow is via DNS records (either an A record, if you can point to a static IP or ALIAS/ANAME if you need CNAME-like functionality).
    – EEAA
    Jul 15, 2016 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.