Setting Up DNS Wildcards / ServerAlias in DirectAdmin

This is straight from their knowlege base, more for my own personal archive than anything else ;)

If you’d like to setup your domain to accept anything.domain.com, you can do so with the following guide (Admin access required)

1) Setup the dns with a wildcard A record. Go to Dns Control, and add an “A” record:
* -> 1.2.3.4
where 1.2.3.4 is the IP of your domain.
This will allow anything.domain.com to resolve to your server. Apache does not yet know how to direct that name though.

2) To setup apache, go to:
Admin Level -> Custom Httpd configurations -> domain.com
In the top text area, add this *one* line:

ServerAlias *.|DOMAIN|
then click “Save”.

That should be it. Wait a few minutes for everything (apache, named) to be restarted then test it out.

The wildcard subdomains will point to your main public_html directory for the domain.
If you want to change this, it’s probably best not to do step 2, and to setup your own custom virtualhost manually into the /etc/httpd/conf/httpd.conf (DA wont delete/overwrite it there) with the same ServerAlias directive as in step 2.

You can then use the mod_rewrite methods Brandon describes to have some real fun with those dynamic sub domains.

Related posts:

  1. One Click Django Project Publishing I was reading The Joel Test and I got to...

Related posts brought to you by Yet Another Related Posts Plugin.

February 2, 2007   Posted in: Programming & Internet

5 Responses

  1. Paul Gardner - June 16, 2008

    Should the ‘ServerAlias *.|DOMAIN|’ go above or below ‘RewriteEngine On’?

  2. Dustin - June 16, 2008

    I don’t think it matters in what order it goes.

  3. Setting up Wildcard DNS & Subdomains on cPanel | Nerdy Dork - September 11, 2008

    [...] posted instructions in the past on how to set up wildcard DNS and subdomains on DirectAdmin. DirectAdmin makes it rather trivial, which is quite nice. There is a little bit more effort [...]

  4. Eric from beat pornography addiction - May 12, 2009

    Thanks Dustin, this helped get it done. Appreciate it.
    Eric

  5. Mike - July 1, 2009

    I find that nerdydork.com is not yet set up to accept anything.nerdydork.com ?! I tried for blog.nerdydork.com! :)Mike

Comments are closed for this entry.