0

We have one static IP on which we have routed our company website. We have setup a local machine on windows with WAMP to run our testing server.

We want virtual hosts to test our different apps. However, when creating subdomains, we have a new project which uses wildcard subdomains. How can we create the wildcard subdomains in VirtualHosts.

We use,

 NameVirtualHost *

<VirtualHost *>
    ServerAdmin admin@test
    DocumentRoot "E:/Wamp/www/corporate"
    ServerName  companysite.com
</VirtualHost> 

<VirtualHost *>
    ServerAdmin admin@test
    DocumentRoot "E:/Wamp/www/project"
    ServerName  project.companysite.com
</VirtualHost>

<VirtualHost *>
    ServerAdmin admin@test
    DocumentRoot "E:/Wamp/www/project"
    ServerName  *.project.companysite.com
</VirtualHost>

However, the last * wildcard does not work. Any help?

0
0

I hope you are using this instead, and the above is just shorthand:

NameVirtualHost *:80
<VirtualHost *:80>
...

Then...

ServerAlias works with wildcards...

<VirtualHost *:80>
    ServerAdmin admin@test
    DocumentRoot "E:/Wamp/www/project"
    ServerName  www.project.companysite.com
    ServerAlias *.project.companysite.com
</VirtualHost>

Though you might have other configuration issues that could cause this to not take effect. I know WampDeveloper is set up for this to work, XAMPP probably too. Could try one of them.

2
  • Yes, server aliases worked perfect. Thank you for that. – Khuram May 31 '11 at 4:36
  • @Khuram, please mark this as the answer so others with a similar issue know what to do. – rightstuff May 31 '11 at 12:56
1

Here's the syntax for ServerName:

It doesn't mention that it supports any sort of wilcard.

The only way to have a "default" host is to use the fact that Apache will load the first <VirtualHost> block when there isn't any ServerName directive that matches the Host header.

1
  • Hi, we have several projects of this nature with multiple wildcard domains. If we make one of them default then other might not load? Thoughts? – Khuram May 30 '11 at 11:56
0

If it helps anyone else who may stumble upon this question there is a simple step-by-step tutorial on setting up subdomains and virtual hosts for Wamp here: http://www.itutorblog.com/2011/06/how-to-create-a-subdomain-on-wamp/

1
  • Welcome to Server Fault! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Chopper3 Jun 25 '11 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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