Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

Is it possible to point wildcard subdomains to a top level domain via DNS settings alone?

I would like to have * redirected to is hosted on a 3rd service. I do not have access to any of my site's apache configuration files.

Thank you, Malcolm

share|improve this question
Can you clarify what the desired result is? You can have a wildcard in DNS but that will just make all those names resolve to some address. In the context of a web site you would still most likely want to do a http permanent redirect to have everyone sent to the same address. – Håkan Lindqvist Jul 19 '14 at 15:27

At a DNS technical level, sure you can have:


Although a better configuration would be:

@      IN SOA ( ... )
       IN A n.n.n.n     ; put your server IP here
www    IN A n.n.n.n     ; and here
*      IN CNAME www

That will ensure that people doing a lookup for the SOA or MX records of don't get an unexpected answer.

However if your web server isn't set up to expect the wildcarded host names that people start using to point at, they'll just get error pages.

For that to work you need something like:

<VirtualHost .....>
ServerAlias *


and that has to be in the main config, not in a .htaccess file.

Alternatively, if the intent is that all wildcard subdomains end up at the same site, use an HTTP-level redirect such that all URLs end up with the client redirected to a preferred canonical URL (e.g. either www or the one without any prefix)

share|improve this answer
Doing as explained here will leave visitors on whatever address they entered. Typically the desired result for web sites is to have one canonical name. (As for the "better configuration", why not skip the use of CNAME altogether?) – Håkan Lindqvist Jul 19 '14 at 15:31
@HåkanLindqvist yes, a redirect to the canonical site might be better, but why downvote for otherwise still useful supplemental information. – Alnitak Jul 20 '14 at 14:02
In retrospect I think you're right, I was overly set on it being a complete answer. My bad. – Håkan Lindqvist Jul 20 '14 at 14:36

Assuming that you can without fail set wildcard (* in DNS on your domain (if not, you can move your domain to for example freedns service).

DNS service only translate domain to IP, i'ts not related to any service (http, ftp, smtp) so it can't redirect http request from one to different domain.

But you can:

  1. Point * to some other web/http server that supports http wildcard and redirect.
  2. Contact your http service provider to setup wildcard on their server

Additionally, most of the popular/used control panels (cPanel, DirectAdmin, ...) supports wildcard so maybe you can set this up yourself.

share|improve this answer

If your DNS provider supports wildcard CNAME then this should work. See Question 44618

share|improve this answer

Your Answer


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