0

The Apache documentation is a bit unclear on the vhost configuration. Where I normally use wampserver, I discovered a discrepancy with XAMPP. Consider the fairly standard httpd.conf in the XAMPP distribution containing among other things:

ServerName localhost:80

DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
</Directory>

And a empty httpd-vhosts.conf file. Everything works as advertised and the content of the xamp/htdocs folder is used (and redirects to /htdocs/dashboard)

As soon as a section is added to file httpd-vhosts.conf, for instance

<VirtualHost *:80>
    ServerName customer01.localhost

    DocumentRoot "D:/Customers/Customer01/httpdocs"
    <Directory  "D:/Customers/Customer01/httpdocs">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

And the proper amendments are made to .../etc/hosts. http://localhost stops working as it now redirects to D:/Customers/Customer01/httpdocs ignoring the ServerName setting in httpd.conf.

Is this by design?

If, however, in addition to the ServerName setting in httpd.conf the following is added to httpd-vhosts.conf:

<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "C:/xampp/htdocs"
  <Directory "C:/xampp/htdocs/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>

things are fine again.

Why is the extra vhost needed as the global ServerName is already set in httpd.conf? Is this something the ApacheFriends should add to vhost by default?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
theking2
  • 2,174
  • 1
  • 27
  • 36

0 Answers0