views:

478

answers:

5

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?

A: 

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").

altCognito
Why do people keep citing obsolete specs? Sigh!
Julian Reschke
+17  A: 

Domain names are not case-sensitive, and Example.com will resolve to the same IP as eXaMpLe.CoM.

The web server, however, may treat the Host header as case-sensitive. (They shouldn't, but things happen.) Same applies to browsers - not all of them care enough to use case-insensitive checks.

grawity
You are right - one of the caching scripts was comparing domain names case-sensitively and was causing the issues. Forcing hostnames to lowercase seems to fix it.
Piskvor
Then, this script is badly broken and must be fixed.
bortzmeyer
+3  A: 

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

Alex Beardsley
+1 for the reference :)
altCognito
We weren't discussing the scheme name. (Also: RFC 1738 is ancient, and has been updated several times since; the current RFC is 3986).
Julian Reschke
A: 

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.

Gili
.COM accepts IDN, too... And IDN changes nothing to the fact that domain names are case-insensitive so café.com and CAFÉ.com are the same.
bortzmeyer
A: 

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.

benc