Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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>

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

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.

127.0.0.1 *.tbi.loc
127.0.0.1 tbi.loc
share|improve this question

migrated from stackoverflow.com Oct 7 '11 at 17:24

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

add comment

2 Answers

  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
add comment

You have to have a valid DNS record that resolves somehost.tbi.loc to 127.0.0.1 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

address=/.tbi.loc/127.0.0.1.

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

share|improve this answer
add comment

Your Answer

 
discard

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.