0

I have a development setup of subdomains with apache/wamp, everything is working as I need with the "regular" setup and separately with the "xyz" setup, but I have to change the configuration and restart the server everytime I need a different setup.

Is there a way to have both setups working at the same time?

I'm looking for answer that allows me to access both setups at the same time without changing the urls or ports I use to access them.

this is my regular setup

<VirtualHost *:9090>
    ServerName localhost.com
    ServerAlias *.localhost.com
    VirtualDocumentRoot u:\wamp\www\subdomains\%1
    <directory "u:\wamp\www\subdomains\%1">
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Deny from all
        Allow from all
    </directory>
</VirtualHost>

This is my secondary (xyz) setup

<VirtualHost *:9090>
    ServerName localhost.com
    ServerAlias *.xyz.localhost.com
    VirtualDocumentRoot u:\wamp\www\subdomains\xyz
    <directory "u:\wamp\www\subdomains\xyz">
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Deny from all
        Allow from all
    </directory>
</VirtualHost>

1 Answers1

2

You are not approaching this quite right.

ServerName and ServerAlias are somewhat redundant. ServerName provides the "primary" name of the virtual host which identifies it where that is required. ServerAlias provides other names which map to the virtual host.

ServerName also does not have to be the actual hostname (with FQDN) of the server. It can be arbitrary, and it can be different for all your virtual hosts.

Assuming that you use www.localhost.com to access one server and www.xyz.localhost.com to access the other, you can simply use localhost.com and xyz.localhost.com for the ServerName paramater, and keep the same wildcards. Keep in mind, however, that xyz.localhost.com will then go to whichever of these virtual hosts appears first (has a filename which comes first in lexical order).

As a side note, do not use domain names you don't own. If your intention is to obfuscate what the actual domain is for the purpose of documentation, use example.net.

Falcon Momot
  • 24,975
  • 13
  • 61
  • 92
  • 1
    Good explanation and solved my situation, I just changed xyz ServerName to xyz.localhost.com and added both configs to the server. I use that domain because I need to match subdomains to folders, I have a special dns setup for that, thanks a lot. – user187450 Aug 28 '13 at 03:13