Wildcard *.domain.com
by admin on Sep.07, 2009, under DirectAdmin
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.
Other similar uses might be subdomain aliasing, where test.domain.com is the same as test.domain2.com.
You can accomplish this by following step 1) above, then insert the following instead of step 2) above:
|*if SUB|
ServerAlias |SUB|.domain2.com
|*endif|
which will make any existing subdomain from domain2.com point to domain.com.
Related posts:
- Adding custom httpd.conf code to the VirtualHosts of a domain DirectAdmin Allows Admin to insert extra httpd.conf code that a...
- How to setup per-domain Aliases If you want to disable /webmail for just one domain...
- Using a custom VirtualHost template If you wish to change the setup of the VirtualHosts...
- How do I change the DocumentRoot of only one of my subdomains? 1) If you wish to change just 1 subdomain path,...
- How to downgrade from apache 2 back to apache 1.3 If you need to go back to apache 1.3 after...
Related posts brought to you by Yet Another Related Posts Plugin.
