Wildcard Subdomains

oliviah

New Member
Hello,

I know to make a "*" A record to enable wildcard subdomains.

But, how do I make a subdomain load a certain page if it has not been created?
 
I'm not quite sure if I got your question right but sounds like you might want to create a virtual host for *.domain.com and put an index page in this vhost's documentroot with the content you need.
 
That may be it... Can you provide instructions?

Basically,
Any existing subdomain (has been created) loads whatever directory it was pointed to at creation.

Any non-existent subdomain (has not been created) it loads a specific directory of my choosing.
 
Apache is going through the config till first match, so you need to add your existing subdomains above the virtualhost which will cover *.domain.com. I'm not quite sure what specific configuration you need the following can be used as a starting point I think:

Code:
<VirtualHost IPADDRESS:80>
   ServerName existing1.domain.com
   ServerAlias www.existing1.domain.com
   DocumentRoot /home/user/public_html/existing1
</VirtualHost>

<VirtualHost IPADDRESS:80>
   ServerName existing2.domain.com
   ServerAlias www.existing2.domain.com
   DocumentRoot /home/user/public_html/existing2
</VirtualHost>

....

<VirtualHost IPADDRESS:80>
   ServerName *.domain.com
   DocumentRoot /home/user/public_html/non-existing/
</VirtualHost>
 
Top