Wildcard Subdomains

Discussion in 'Linux VPS/Dedicated - cPanel' started by oliviah, Apr 26, 2010.

  1. oliviah

    oliviah New Member


    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?
  2. KH-Paul

    KH-Paul CTO Staff Member

    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.
  3. oliviah

    oliviah New Member

    That may be it... Can you provide instructions?

    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.
  4. KH-Paul

    KH-Paul CTO Staff Member

    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:

    <VirtualHost IPADDRESS:80>
       ServerName existing1.domain.com
       ServerAlias www.existing1.domain.com
       DocumentRoot /home/user/public_html/existing1
    <VirtualHost IPADDRESS:80>
       ServerName existing2.domain.com
       ServerAlias www.existing2.domain.com
       DocumentRoot /home/user/public_html/existing2
    <VirtualHost IPADDRESS:80>
       ServerName *.domain.com
       DocumentRoot /home/user/public_html/non-existing/

Share This Page