0

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

2 Answers 2

1
  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.

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .