[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3015
  • Last Modified:

How to create subdomains and NOT use DNS


I would like to be able to create subdomains on our Apache 2 webserver.

I DO NOT want to add these sub domains to our DNS (currently using third party website).


mydomain.com <- All requests go here

sub.mydomain <- All requests go to root document for this subdomain WITHOUT using DNS

Here is my current configuration but only works with DNS etries:

ServerAdmin webmaster@mydomain.com
DocumentRoot /root/subdir
DirectoryIndex index.html index.htm index.php index.cgi
ServerName sub.mydomain.com
ErrorLog /var/log/httpd/subdir/error_log
CustomLog /var/log/httpd/subdir/access_log custom env=!object

I hope this question makes sense and I hope this is possible.


1 Solution
> I DO NOT want to add these sub domains to our DNS

Then you must add a wildcard DNS entry like

*.example.com. 172800 IN A IP_goes_here

Otherwise the request does not reach your server.
caterham_www is correct - in order for a webpage of a subdomain to be resolved, you need both a dns entry that covers that subdomain, and an apache configuration that covers this domain as well.

If you do not want to specify out each subdomain, you need a wildcard entry like he has specified, as well as some form of default virtualhost configuration, that will pick up the subdomains.

also as you said

I DO NOT want to add these sub domains to our DNS (currently using third party website).
======== Than ofcourse you can add your subdomains entry in some remote DNS server that resolve to your apache. It is not necessary to have DNS server on same server. But the DNS server name you add your subdomians must be one of the nameserver define for that Domain...

i.e. if you domain is hosted on your server with nameserver as ns1.domain.com and ns2.GenericNameserver.com
and ns1.domain.com is on your server but ns2.GenericNameserver.com belongs to some other server of some hosting company. Than just add your sub-domain DNS entry in there server, and put virtual tag in your apache.

DNS server are to resolve the name to IP once it is done either by your server or by remote it doesn't matter to a request they will get your subdomains IP thats all they need

But for simplicity follow what has been said above ...

Though I am interested to know why you need to do that, if you have a subdomain register it in DNS why you don't want will be interesting...

baxleybAuthor Commented:
periwinkle,  caterham_www,

Thanks for your posts. We are currently using DNS to resolve sub-domains but would like the flexibility to NOT use DNS to accomplish this.

So if I did use a wildcard then would EVERY sub domain attempt to resolve to one ip address?

What if I had like 5 that should go to different ip addresses? How would that work?


anotherserver.mydomain.com ->

anotherserver.mydomain.com ->

*.mydomain.com ->

anotherserver.mydomain.com ->



baxleybAuthor Commented:
Well I found out that I can use a wildcard, but it has been decided to do this at a later time, for now we'll stick with direct to DNS.

caterham_www, thanks for your advice and response.



Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Tackle projects and never again get stuck behind a technical roadblock.
Join Now