1

Where * is different for each client like apple.example.com, pearl.example.com. These all should be routed to the same IP and same directory. How to modify the hosts file and the httpd config?

More detailed example:

<VirtualHost 111.22.33.44>
    ServerName                 customer-1.example.com
    DocumentRoot        "/www/hosts/example.com/docs"
    ScriptAlias  "/cgi-bin/"  "/www/hosts/example.com/cgi-bin"
</VirtualHost>

<VirtualHost 111.22.33.44>
    ServerName                 customer-2.example.com
    DocumentRoot        "/www/hosts/example.com/docs"
    ScriptAlias  "/cgi-bin/"  "/www/hosts/example.com/cgi-bin"
</VirtualHost>

<VirtualHost 111.22.33.44>
    ServerName                 customer-N.example.com
    DocumentRoot        "/www/hosts/example.com/docs"
    ScriptAlias  "/cgi-bin/"  "/www/hosts/example.com/cgi-bin"
</VirtualHost>

Thanks!

1 Answer 1

0

You can use star in ServerAlias like this:

<VirtualHost 111.22.33.44>
    ServerName      customer-1.example.com
    ServerAlias     *.example.com
    DocumentRoot    "/www/hosts/example.com/docs"
    ScriptAlias     "/cgi-bin/"  "/www/hosts/example.com/cgi-bin"
</VirtualHost>
3
  • So do I have to add all aliases to the hosts file or can I also use *.example.com there (That does not seem to work that way.)?
    – Hey.There
    Commented May 28, 2017 at 9:14
  • As i understand, you need to serve all subdomains with one directory, so you can use ServerAlias. is it? Commented May 28, 2017 at 9:22
  • By installing this: Acrylic DNS Proxy the wildcards started to work in the hosts file, the server config you gave is fine and working. :)
    – Hey.There
    Commented May 28, 2017 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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