Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to replicate the setup I have a remote server on my local server/machine, that is, having wildcard subdomains with the following virtual hosts in place.

<VirtualHost *:80>
    DocumentRoot "/Users/User/Sites/tbi"
    ServerName tbi.loc

<VirtualHost *:80>
    DocumentRoot "/Users/User/Sites/tbi"
    ServerName subdomains.tbi.loc
    ServerAlias *.tbi.loc

This setup doesn't seem to work. I do have access to http://tbi.loc, but I cannot connect to any subdomains. What I aim to accomplish is having the www subdomain for non-registered visitors and a separate subdomain for each registered user.

The document root for both virtual hosts is the same (I have tried using different document roots to no avail) since I determine what needs to happen based on the subdomain.

Please, note that I would like to accomplish this without having to rely on .htaccess (if at all possible).

The Apache hosts file contains two entries for this virtual host. *.tbi.loc tbi.loc
share|improve this question

migrated from Oct 7 '11 at 17:24

This question came from our site for professional and enthusiast programmers.

  1. Do you have NameVirtualHost *:80 configured in you apache config? If not, it would give the tbi.loc site when connecting to www.tbi.loc.

  2. Do you have dns/hostfile entries for www.tbi.loc, subdomain.dbi.loc, *.tbi.loc pointing to your test server? If not, your browser wouldn't know where to connect to.

share|improve this answer

You have to have a valid DNS record that resolves somehost.tbi.loc to and *.tbi.loc in the hosts file doesn't do this as the hosts file doesn't accept wildcard entries.

You don't say whic OS you are using but if you OS supports it then you can easily configure dnsmasq with wildcard entries for *.tbi.loc


Once you resolve your DNS issues everything else should start to work.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.