note 15394 deleted from language.variables.predefined by jimw
| From: | jimw@php.net | Date: | Fri, 14 Dec 2001 19:26:10 +0000 |
| Subject: | note 15394 deleted from language.variables.predefined by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-22656@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