note 15394 added to language.variables.predefined
| From: | pete at SoulCoffee dot org | Date: | Fri, 07 Sep 2001 20:00:35 +0000 |
| Subject: | note 15394 added to language.variables.predefined | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-17788@lists.php.net to get a copy of this message | ||
Case Sensitivity counts in browsers > 5.0<br>
In one of my pages, I check to make sure the server listed in the URI is actually the server on
which my pages are hosted. This prevents redirection spoofing, and also fixes the ServerAlias for
hosting providers that may not be friendly about httpd.conf changes.<br>
My original code read like this:<br>
if (strcmp($HTTP_SERVER_VARS["HTTP_HOST"],$hostname)!=0) {
// Put header redirection code here...
}<br>
but that failed on Netscape 6 and IE 5+. After a bit of digging, I found that the newer browsers
returned what was typed in the browser location field, and NOT what was specified in the httpd.conf
as the ServerName. There is probably a more correct explanation, but that is left as an exercise for
the reader. =)<br>
To fix the problem, lowercase your strings before comparing them, like so:<br>
if (strcmp(strtolower($HTTP_SERVER_VARS["HTTP_HOST"]),strtolower($hostname))!=0) {
// Put header redirection code here...
}<br>
Pete
http://www.php.net/manual/en/language.variables.predefined.php