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!

Hey.There
  • 15
  • 5

1 Answers1

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>
Mohammad Hamedani
  • 3,179
  • 3
  • 8
  • 21
  • 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 May 28 '17 at 09:14
  • As i understand, you need to serve all subdomains with one directory, so you can use **ServerAlias**. is it? – Mohammad Hamedani May 28 '17 at 09: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 May 28 '17 at 09:45