14

Let's that I've got the domain mydomain.com.

I want that when any visitor goes to
www.mydomain.com
xyz.mydomain.com
abc.mydomain.com
asd.mydomain.com
qwe.mydomain.com
etc...

the visitor will continue seeing "xyz.mydomain.com", but the real address will be "mydomain.com". my asp.net application will handle the differences between the addresses. I want that the subdomain can be anything.

The problem is: I'm using a shared host. They allow me to create subdomains and allow me to create some DNS records:

Address (A)
CNAME
Mail (MX)
IPV6 (AAAA)
TXT

Is it possible to set up my hosting to accept that asterisk/wildcards for subdomains? How do I do it?

Click Ok
  • 956
  • 4
  • 12
  • 18
  • You should consider the SEO implications of this. – Dave Cheney May 26 '09 at 04:12
  • What SEO implications? Do the search engines demote listings from wildcarded sites or that aren't www.{domain} ? – Alnitak May 26 '09 at 08:59
  • 1
    If x.abc.com and y.abc.com contain the same information, they will: a) be diluted b) possibly be demoted for "googlebombing" -- setting up multiple identical sites is considered bad form by search engines. A better solution might be to redirect *.abc.com to www.abc.com. – Ben Doom Jul 27 '09 at 18:03
  • It's not a problem. Just use canonical urls: https://support.google.com/webmasters/answer/139066?hl=en – Leonard Challis Jun 12 '14 at 08:18

3 Answers3

12

Some advice against wildcard web sites:

What will you do when someone starts publicizing your website as "http://this.company.sucks.domain.com" and it resolves / renders correctly?

James F
  • 6,689
  • 1
  • 26
  • 24
  • Agreed. Just make a single A record for the hostname of the server and then you can make aliases for the websites themselves. Doing this will help you if you ever need to change IP addresses again. – Tatas Jul 25 '09 at 17:33
  • 3
    The use case for this is usually for things like account_name.example.com in web applications - highly useful, and a nightmare to set up manually on a DNS server if you've lots of signups. If someone publicises this.company.sucks.example.com, you can always set up a spurious A record for that particular subdomain. – ceejayoz Dec 17 '09 at 22:15
  • 2
    Or in your Web server software, where I assume you would alias xyz.example.com to the xyz site, have any unmatched queries (still pointing at the same server) use a normal redirect, so the browser changes to example.com or www.example.com. You could even throw in a 404 page at the end of the redirect. – mpbloch Apr 12 '10 at 00:30
  • 1
    Having a wildcard DNS does not mean that the webserver delivers a website for each possible name. The webserver has to be configured seperately. For example it would be possible to configure a webserver so it delivers only USRNAME.example.com but not anything else. – mit Apr 22 '15 at 10:02
  • HTTP Connection to the server published with wildcard domain will receive the `Host` header with the connection. If you have wildcard DNS entry, you're supposed to host e.g. wildcard HTTP server so it can just return custom error page for host names that you don't want to serve. If you have wildcard TLS certificate, you can make it work without SNI, too. – Mikko Rantalainen Jan 12 '21 at 12:27
  • DNS can point to your server but the server doesn't need to resolve. The application logic will determine (based on database records) whether it should resolve a given subdomain or not. The "http://this.company.sucks.domain.com" argument is mute. – Lambder Oct 21 '22 at 10:01
9

Try creating an A or CNAME record with * as the subdomain and your server's IP (A record) or domain (CNAME record) as the destination. If your host's control panel doesn't permit a wildcard, you'll have to contact them for help, or move your DNS to a third party.

ceejayoz
  • 32,910
  • 7
  • 82
  • 106
5

A Bind DNS server allows you to create wildcard A records like this:

*.mydomain.com. IN A x.x.x.x

Or, if they are using a web control panel, create an A record for the host * , at your IP address.

Windows 2000 DNS server takes some effort to use wildcarding:

Step 1. Enable LooseWildcarding. Loose Wildcarding http://technet.microsoft.com/en-us/library/cc940790.aspx

Step 2. Use Dnscmd to create the Wildcard record. http://support.microsoft.com/default.aspx?scid=kb;en-us;840687

I'm not sure about Server 2003 and newer - there was an issue with wildcards in Server 2003 DNS not working if you have WINS forward lookup enabled

Mike
  • 659
  • 1
  • 6
  • 7