php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29083 $_SERVER["SERVER_NAME"] and $_SERVER["HTTP_HOST"] Output the same thing
Submitted: 2004-07-10 11:52 UTC Modified: 2004-07-11 19:00 UTC
From: nathan at inimit dot com Assigned:
Status: Not a bug Package: Apache2 related
PHP Version: 4.3.7 OS: Freebsd 4.8
Private report: No CVE-ID: None
 [2004-07-10 11:52 UTC] nathan at inimit dot com
Description:
------------
Based on the output, SERVER_NAME should output the ServerName value within the VirtualHost entry within the httpd.conf while instead it is outputing the current hostname which could be any of the ServerAlias entries.

I have setup PHP 4.3.7 with:

'./configure' '--enable-versioning' '--enable-memory-limit' '--with-layout=GNU' '--with-zlib-dir=/usr' '--disable-all' '--with-regex=php' '--with-pear' '--enable-bcmath' '--enable-ctype' '--with-curl=/usr/local' '--with-db4=/usr/local' '--enable-dba' '--with-dom=/usr/local' '--with-dom-xslt=/usr/local' '--with-dom-exslt=/usr/local' '--enable-ftp' '--with-gd' '--enable-gd-native-ttf' '--with-freetype-dir=/usr/local' '--with-t1lib=/usr/local' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-xpm-dir=/usr/X11R6' '--with-iconv-dir=/usr/local' '--enable-mbstring' '--with-mcrypt=/usr/local' '--with-mhash=/usr/local' '--with-mime-magic=/usr/share/misc/magic.mime' '--with-mysql=/usr/local' '--with-openssl-dir=/usr/local' '--with-openssl=/usr/local' '--enable-overload' '--with-pcre-regex=yes' '--enable-posix' '--with-pgsql=/usr/local' '--with-pspell=/usr/local' '--enable-session' '--enable-sockets' '--enable-tokenizer' '--with-expat-dir=/usr/local' '--enable-xml' '--with-xmlrpc' '--enable-xslt' '--with-xslt-sablot=/usr/local' '--with-zlib=yes' '--with-apxs2=/usr/local/sbin/apxs' '--x-libraries=/usr/X11R6/lib' '--x-includes=/usr/X11R6/include' '--prefix=/usr/local' 'i386-portbld-freebsd4.8' 

nshb# uname -a
FreeBSD nshb.inimit.ca 4.8-RELEASE FreeBSD 4.8-RELEASE #0: Thu Apr  3 10:53:38 GMT 2003     root@freebsd-stable.sentex.ca:/usr/obj/usr/src/sys/GENERIC  i386

<VirtualHost *>
    ServerAdmin webmaster@inimit.com
    DocumentRoot /domains/inimit.com/www/wwwroot
    ServerName inimit.com
    ServerAlias www.inimit.com
    ErrorLog /domains/inimit.com/www/logs/error.log
    CustomLog /domains/inimit.com/www/logs/access.log common
</VirtualHost> 

Reproduce code:
---------------
<?php
echo $_SERVER["SERVER_NAME"];

echo $_SERVER["HTTP_HOST"];
?>

Expected result:
----------------
Result: (If on http://inimit.com)

inimit.com

inimit.com

Result: (If on http://www.inimit.com)

inimit.com

www.inimit.com



Actual result:
--------------
Result: (If on http://inimit.com)

inimit.com

inimit.com

Result: (If on http://www.inimit.com)

www.inimit.com

www.inimit.com



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-11 19:00 UTC] sniper@php.net
These variables are set by the webserver, not by PHP. 
Read more at:
http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC