11

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?

4

5 回答 5

24

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.

于 2009-06-02T16:25:39.167 回答
5

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

于 2009-06-02T16:27:09.370 回答
4

由于您将问题表述为实际问题,然后描述了现实世界的问题,因此答案实际上是:是的。

关于 RFC 规范关于主机名的内容,其他答案是正确的。从技术上讲,它们应该不区分大小写。(事实上​​,较早的约定是顶级域(TLD)应该全部大写......比如“apple.COM”)。

然而,在现实世界中,像操作系统解析器和主流浏览器这样的成熟软件可以做到这一点。任何类型的辅助代码都可能会处理这个错误,并把你搞砸。

于 2009-07-17T07:35:04.613 回答
1

根据https://www.rfc-editor.org/rfc/rfc1035

对于作为官方协议一部分的 DNS 的所有部分,字符串(例如,标签、域名等)之间的所有比较都以不区分大小写的方式进行。目前,该规则无一例外地在整个域系统中生效。

然后它继续说这可能会在未来发生变化。我认为可以安全地假设 COM 域不区分大小写,但其他允许使用非 ASCII 字符的域可能会有所不同。

于 2009-06-02T16:28:38.323 回答
0

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

于 2009-06-02T16:25:07.667 回答