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

I would like to have *.mydomain.com redirected to mydomain.com.

mydomain.com is hosted on a 3rd service. I do not have access to any of my site's apache configuration files.

Thank you, Malcolm

link|improve this question
feedback

3 Answers

At a DNS technical level, sure you can have:

*.example.com. IN CNAME example.com.

Although a better configuration would be:

$ORIGIN example.com.
@      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 foo.example.com 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 .....>
ServerName wwww.example.com
ServerAlias example.com
ServerAlias *.example.com

</VirtualHost>

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

link|improve this answer
feedback

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

link|improve this answer
feedback

If you have FTP access to mydomain.com you could just put in a .htaccess file with the redirect. You don't need access to the apache configuration for this.

link|improve this answer
This won't help without the DNS configured correctly, and that's depending on if you want a redirection or not. – Mark Henderson Jul 12 '10 at 5:39
feedback

Your Answer

 
or
required, but never shown