How to set the same document root for all server names on Apache

166 views Asked by At

I need a way to make all server names point to one document root without the need to manually type them all, maybe something like this:

<VirtualHost *:80>
   DocumentRoot /www/example1
   ServerName *
</VirtualHost>

Will that work?

1

There are 1 answers

0
Andrew Schulman On

No, you can't write ServerName *.

All you have to do is put the DocumentRoot in the first virtual host that gets read in your configuration. The Apache Name-Based Virtual Hosts guide explains that any server whose name doesn't match the ServerName in any virtual host configuration will be served by the default host, so it will get the DocumentRoot you want.