httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Boyle Owen" <>
Subject RE: ServerPath
Date Mon, 12 Aug 2002 13:09:44 GMT
>From: Werner Schalk []
>I did not get the point that
>the ServerPath directive is
>used for. Could somebody be
>so kind to explain it to me?

I've never had occasion to use this curious little directive but your question intrigued me
so I read the documentation and it seems those Apache folks have thought of everything...
They have considered the problem which arises when a CLIENT which only speaks HTTP/1.0 tries
to access a name-based virtual host. Since the "Host" header is not mandatory in HTTP/1.0,
such a client doesn't send one. Which means apache cannot decide which VH to serve - so it
just serves the first one!

To workaround this, you have the possibility of defining the ServerPath - what this does is
allows apache to recognise the virtualhost based on the path section of the URI. E.g.

banana and kiwi both resolve to


  ServerName banana
  DocumentRoot /home/banana/html

  ServerName kiwi
  ServerPath /nz/birds
  DocumentRoot /home/kiwi/html

In HTTP/1.1:

http://banana/cr/trees --> /home/banana/html/cr/trees
http://kiwi/nz/birds --> /home/kiwi/html/nz/birds

Which is what the webmaster wants.

However, if an HTTP/1.0 client requests http://kiwi/nz/birds, it won't send any Host header
and so the server will see With no Host to match against a ServerName,
apache would look in VH1, not find the directory and you'd get a 404.

To cope with this, the ServerPath directive allows apache to match the "/nz/birds" in the
request with VH2. Now apache goes into VH2 and finds the directory.

There are a couple of obvious snags with this set-up: 

- since banana also resolves to the same IP, http://banana/nz/birds works! This might be regarded
as a bit weird...

- If you have a symmetric directory structure in the two VHs, this technique wouldn't work
(e.g. http://banana/flavour and http://kiwi/flavour would require "ServerPath /flavour" in
both VHs which would render them indistinguishable again).

If you happen to have a lot of complaints from customers who use ancient browsers (Mosaic?)
then you might need to worry about this directive, however, at the risk of being flamed by
whoever thought it up, I'd suggest that this directive is not really necessary anymore and
that nobody would notice if you just forgot about it ;-)


Owen Boyle

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message