All URLs on *nix servers are case-sensitive. Some URLs on Windows servers are also case-sensitive.
Edit: The domain name is case-insensitive (actually, the client converts it to lowercase).
http://user:[email protected]/somedir/somefile.ext?someQueryString=someValue#fragment
=======----------==========--------------------------------------------------------
Legend:
- : Case sensitive
= : Case insensitive
Note: By specification fragments are supposed to be case sensitive but it is not implemented that way on all clients.
This is a very bad idea to do what you are trying to do. The best way would be to just lowercase the domain name.
Edit 2: Since you asked, here is a function that will properly lowercase a given URL (scheme and domain only):
function urltolower($url) {
$parts = @parse_url($url);
if($parts === FALSE) return FALSE;
$url = '';
if(!empty($parts['scheme'])) $url .= strtolower($parts['scheme']) . (($parts['scheme'] == 'file') ? ':///' : '://');
if(!empty($parts['user'])) $url .= $parts['user'] . ((!empty($parts['pass'])) ? ':' . $parts['pass'] : '') . '@';
if(!empty($parts['host'])) $url .= strtolower($parts['host']);
if(!empty($parts['port'])) $url .= ':' . $parts['port'];
if(!empty($parts['path'])) $url .= $parts['path'];
if(!empty($parts['query'])) $url .= '?' . $parts['query'];
if(!empty($parts['fragment'])) $url .= '#' . $parts['fragment'];
return $url;
}
[mixed] urltolower($url)
Lowercases an URL. Returns FALSE
on failure. Returns lowercased URL on success.
Example:
echo urltolower('HTTP://en.WikiPedia.org/wiki/PHP');
//echo's http://en.wikipedia.org/wiki/PHP