note 13100 deleted from ref.url by philip

From: Date: Thu, 03 Sep 2015 02:31:16 +0000
Subject: note 13100 deleted from ref.url by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-203596@lists.php.net to get a copy of this message
Note Submitter: verdy_p at wanadoo dot fr ---- Warning: when the PHP engine runs for your hosted web site, it may execute on a domain name which is completely different than the one the user requested in its browser. Many free web hosting site use proxies and/or multiple DNS entries for your hosted web site. This means that: - the IP of the web server can change if multiple DNS entries are present (there may be several web servers running concurrently) - reverse DNS name from the IP may give different domain name over time, or if the domain name is a CNAME only for a virtual web server hosting many domains - the server running PHP may be different than the web server - the web server may be hidden behind a proxy which balances the load between a farm of servers - the queried host name in the HTTP headers may be different than the queried host name in the browser, if behind a redirecting proxy - the actual path name of the ressource may be also different, with additional path elements: this is very common on free hosting servers, where you get a virtual CNAME domain, which gets translated by a proxy into an actual web server, and a domain-specific document root directory So when thinking about using absolute path names you can retreive from PHP, beware that this may not be accurate to insert as absolute URL's in the HTML code built with PHP. The best solution is then to ALWAYS USE relative URLs to reference documents and form scripts on your local server ! This applies to $PHP_SELF too, because it's an absolute pathname: don't use it directly but you can safely use basename($PHP_SELF) to reference your script within HTML forms: <? $self=basename($PHP_SELF); ?> <HTML><HEAD> ... </HEAD><BODY> <FORM method="GET" action="$self"> ... </FORM> </BODY></HTML>

« previous php.notes (#203596) next »