Does HTTP hostname case (upper/lower) matter?
-
06-09-2019 - |
Question
In other words, does it matter whether I use http://www.example.com/ or http://wwW.exAmPLe.COm/ ?
I've been running into strange issues with host-names lately: I have an Apache2.2+PHP5.1.4 webserver, accessed by all kinds of browsers. IE6 users in particular (esp. when their UA string is burdened with numerous BHOs, no pattern yet) seem to have problems accessing the site (cookies disappear, JS refuses to load) when entering via http://www.Example.com/, but not http://www.example.com/
I've checked the HTTP and DNS RFCs, my P3P policies, cookie settings and SOP; yet nowhere I've seen even a mention of domain names being case-sensitive.
(I know path and query string are case sensitive ( ?x=foo
is different from ?x=Foo
) and treat them appropriately; am doing no parsing/processing on domain name in my code)
Am I doing something wrong or is this just some browser+toolbar crap I should work around?
Solution
Domain names are not case-sensitive; Example.com
will resolve to the same IP as eXaMpLe.CoM
. If a web server or browser treats the Host
header as case-sensitive, that's a bug.
OTHER TIPS
No, this shouldn't make any difference.
Check out the URL RFC Spec (http://www.ietf.org/rfc/rfc1738.txt). From section 2.1:
For resiliency, programs interpreting URLs should treat upper case letters as equivalent to lower case in scheme names
Since you worded your question as a practical question, and then described a real-world problem, the answer is actually: YES.
The other answers are correct about the what the RFC spec says about hostnames. Technically they should be case-insensitive. (In fact, the older convention was that the top-level domain (TLD) was supposed to be in all caps... like "apple.COM").
However, on in the real world, mature software like OS resolvers and major browsers get this right. Any kind of secondary code could be handling this wrong, and messing you up.
According to http://tools.ietf.org/html/rfc1035:
For all parts of the DNS that are part of the official protocol, all comparisons between character strings (e.g., labels, domain names, etc.) are done in a case-insensitive manner. At present, this rule is in force throughout the domain system without exception.
It then goes on to say that this might change in the future. I think it is safe to assume that the COM domain is case-insensitive, but other domains allowing the use of non-ASCII characters might differ.
No, there is no case sensitivity with regards to the protocol specifier.
You can see this in the RFC for URLs.
2.1. The main parts of URLs
Scheme names consist of a sequence of characters. The lower case letters "a"--"z", digits, and the characters plus ("+"), period ("."), and hyphen ("-") are allowed. For resiliency, programs interpreting URLs should treat upper case letters as equivalent to lower case in scheme names (e.g., allow "HTTP" as well as "http").