php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51101 $_SERVER['SERVER_NAME'] incorrectly returns the HTTP Host header
Submitted: 2010-02-20 21:26 UTC Modified: 2010-02-20 21:48 UTC
From: balusc at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.1 OS: Windows XP
Private report: No CVE-ID: None
 [2010-02-20 21:26 UTC] balusc at gmail dot com
Description:
------------
Environment: XAMPP 1.7.3 with Apache HTTPD 2.2.14 and PHP 5.3.1 on Windows XP SP3.

Problem: $_SERVER['SERVER_NAME'] incorrectly returns the HTTP Host header.

The $_SERVER['SERVER_NAME'] is supposed to return the server name as definied in the webserver. In this case, the ServerName property of Apache HTTPD's httpd.conf. It instead returns the HTTP Host header.

This is likely a bug in the php5_module used. There was a similar bug report earlier http://bugs.php.net/bug.php?id=16867 but it was forwarded to Apache developers while the problem is likely in the php5_module.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-20 21:28 UTC] rasmus@php.net
As explained in the bug you are referencing, PHP doesn't set this at 
all.  The value comes from the web server.  If it is not set correctly, 
it is because your web server got it wrong.
 [2010-02-20 21:40 UTC] balusc at gmail dot com
It's 5 year old and I don't seem to find anything related at the bug database of the Apache guys. Is the php5_module really doing things right? Is it querying the right key value from the Apache Server? I'll file a bug to the Apache guys anyway.
 [2010-02-20 21:48 UTC] balusc at gmail dot com
Right: 
https://issues.apache.org/bugzilla/show_bug.cgi?id=44614
http://httpd.apache.org/docs/2.2/mod/core.html#usecanonicalname

Sorry for the inconvenience. I would however opt to take this info in the PHP documentation about SERVER_NAME.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 23:01:30 2024 UTC