| Nicolas Lehuen 2005-11-30, 5:48 pm |
| 2005/11/30, Jorey Bump <list@joreybump.com>:
>
> Finally, I'm getting the impression that most developers are looking for
> a portable way to get the ServerName, as defined in the Apache
> configuration. This may currently be achieved in a variety of ways,
> including:
>
> servername = req.server.server_hostname
>
> or:
>
> req.add_common_vars()
> servername = req.subprocess_env['SERVER_NAME']
>
> So, getting back to Nicolas' original post, and reaffirming Grisha's
> point that req.hostname isn't appropriate in his script, maybe
> req.server.server_hostname will work, in that it allows one to construct
> an URL that gets the user back to the site, even if it doesn't exactly
> match the URL displayed in the browser during the original request.
>
> Does the fact that this is a difficult discovery warrant the addition of
> another high-level attribute, req.servername?
The problem, as I've mentioned in my previous post, is that ServerName does
not mean anything in mass virtual hosting environments, at least in my
current settings (I don't exclude the fact that I've done something wrong).
Using the test script provided in my previous post, the ServerName value is
consistently wrong, always being equal to 'localhost' even if it's not the
virtual host that was requested and serviced.
Anyway, like I've wrote, maybe mass virtual hosting is a stupid idea, all
the more since my production server only has 30 or so virtual hosts, so I
could manage them all by traditional VirtualHost directives... At least with
true VirtualHost directives it's easy to set and use the ServerName value.
Regards,
Nicolas
|