In other words, does it matter whether I use http://www.example.com/ or http://wwW.exAmPLe.COm/ ?
换句话说,我使用http://www.example.com/或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/
我最近遇到了主机名的奇怪问题:我有一个Apache2.2 + PHP5.1.4网络服务器,可以被各种浏览器访问。特别是IE6用户(特别是当他们的UA字符串背负着大量的BHO,没有模式时)似乎在通过http://www.Example.com/进入时访问网站(cookie消失,JS拒绝加载)时出现问题,但不是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.
我检查了HTTP和DNS RFC,我的P3P策略,cookie设置和SOP;然而,我甚至没有看到提到域名区分大小写。
(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)
(我知道路径和查询字符串区分大小写(?x = foo与?x = Foo不同)并对其进行适当处理;我的代码中没有对域名进行解析/处理)
Am I doing something wrong or is this just some browser+toolbar crap I should work around?
我做错了什么或者这只是一些浏览器+工具栏废话我应该解决?
5 个解决方案
#1
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.
域名不区分大小写; Example.com将解析为与eXaMpLe.CoM相同的IP。如果Web服务器或浏览器将Host标头视为区分大小写,则表示存在错误。
#2
No, this shouldn't make any difference.
不,这不应该有任何区别。
Check out the URL RFC Spec (http://www.ietf.org/rfc/rfc1738.txt). From section 2.1:
查看URL RFC Spec(http://www.ietf.org/rfc/rfc1738.txt)。从第2.1节:
For resiliency, programs interpreting URLs should treat upper case letters as equivalent to lower case in scheme names
对于弹性,解释URL的程序应将大写字母视为与方案名称中的小写字母等效
#3
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").
其他答案对于RFC规范关于主机名的说法是正确的。从技术上讲,它们应该不区分大小写。 (事实上,较旧的惯例是*域名(TLD)应该是全部大写的......比如“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.
然而,在现实世界中,像OS解析器和主流浏览器这样的成熟软件可以做到这一点。任何类型的二级代码都可以处理这个错误,并搞砸了你。
#4
According to http://tools.ietf.org/html/rfc1035:
根据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.
对于作为官方协议一部分的DNS的所有部分,字符串(例如,标签,域名等)之间的所有比较都是以不区分大小写的方式完成的。目前,该规则在整个域系统中毫无例外地生效。
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.
然后接着说,这可能会在未来发生变化。我认为可以安全地假设COM域不区分大小写,但允许使用非ASCII字符的其他域可能会有所不同。
#5
No, there is no case sensitivity with regards to the protocol specifier.
不,对于协议说明符没有区分大小写。
You can see this in the RFC for URLs.
您可以在RFC for URL中看到这一点。
2.1. The main parts of URLs
2.1。 URL的主要部分
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").
方案名称由一系列字符组成。允许使用小写字母“a” - “z”,数字和字符加(“+”),句点(“。”)和连字符(“ - ”)。为了弹性,解释URL的程序应将大写字母视为与方案名称中的小写字母等效(例如,允许“HTTP”以及“http”)。
#1
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.
域名不区分大小写; Example.com将解析为与eXaMpLe.CoM相同的IP。如果Web服务器或浏览器将Host标头视为区分大小写,则表示存在错误。
#2
No, this shouldn't make any difference.
不,这不应该有任何区别。
Check out the URL RFC Spec (http://www.ietf.org/rfc/rfc1738.txt). From section 2.1:
查看URL RFC Spec(http://www.ietf.org/rfc/rfc1738.txt)。从第2.1节:
For resiliency, programs interpreting URLs should treat upper case letters as equivalent to lower case in scheme names
对于弹性,解释URL的程序应将大写字母视为与方案名称中的小写字母等效
#3
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").
其他答案对于RFC规范关于主机名的说法是正确的。从技术上讲,它们应该不区分大小写。 (事实上,较旧的惯例是*域名(TLD)应该是全部大写的......比如“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.
然而,在现实世界中,像OS解析器和主流浏览器这样的成熟软件可以做到这一点。任何类型的二级代码都可以处理这个错误,并搞砸了你。
#4
According to http://tools.ietf.org/html/rfc1035:
根据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.
对于作为官方协议一部分的DNS的所有部分,字符串(例如,标签,域名等)之间的所有比较都是以不区分大小写的方式完成的。目前,该规则在整个域系统中毫无例外地生效。
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.
然后接着说,这可能会在未来发生变化。我认为可以安全地假设COM域不区分大小写,但允许使用非ASCII字符的其他域可能会有所不同。
#5
No, there is no case sensitivity with regards to the protocol specifier.
不,对于协议说明符没有区分大小写。
You can see this in the RFC for URLs.
您可以在RFC for URL中看到这一点。
2.1. The main parts of URLs
2.1。 URL的主要部分
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").
方案名称由一系列字符组成。允许使用小写字母“a” - “z”,数字和字符加(“+”),句点(“。”)和连字符(“ - ”)。为了弹性,解释URL的程序应将大写字母视为与方案名称中的小写字母等效(例如,允许“HTTP”以及“http”)。