子域中允许使用哪些字符?
子域中允许使用哪些字符?
示例:对于 someSub.example.com
的 someSub
部分。
我知道您可以使用字母、数字和连字符,但是其他字符呢?可以使用_
(下划线)吗?
What characters are you allowed to use in a subdomain?
Example: for someSub.example.com
the someSub
portion.
I know you can use letters, numbers, and hyphens, but what about other characters? Can _
(underscore) be used?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
字母(重音 à 除外)、数字 0-9 和连字符。
http://en.wikipedia.org/wiki/Domain_name
摘抄:
域名中可以使用的有效字符有:
来自 https://www.rfc-editor。组织/rfc/rfc1035
Letters (except stressed à), Numbers 0-9 and Hyphen.
http://en.wikipedia.org/wiki/Domain_name
excerpt:
Valid characters that can be used in a domain name are:
From https://www.rfc-editor.org/rfc/rfc1035
根据此页面,一些顶级域现在允许本地化字符(不仅仅是 az)。
所以,看起来我们需要回到正则表达式的绘图板上。
According to this page, some top level domains now allow localized characters (not just a-z).
So, looks like we need to go back to the drawing board on that regex.
从技术上讲,William 是对的,子域中只允许使用字母、数字和连字符 (-)。
然而:在实践中,您会发现下划线(_)也适用于所有主流浏览器,但这并不能保证。某些提供商和其他服务可能不允许您在 DNS 中进行设置。
如果您在 DNS 中设置通配符,它将进行解析,然后由实际应用程序采用或忽略它。
Technically William is right, and only letters, numbers and hyphen (-) are allowed in subdomains.
However: in practice, you will see that underscore (_) will also work in all major browsers, but this is not guaranteed. Some providers and other services may not allow you to set it in DNS.
If you set a wildcard in DNS it will resolve, then then it is up to the actual application to take it or ignore it.
讽刺的是,这个问题的其他答案是“主机名或主域的合法字符是什么”问题的正确答案,而 问题“can(主机名)子域有下划线”是此问题的正确答案。
Ironically, the other answers to this questions are correct answers to the question "what are the legal characters for a hostname or primary domain", while the answers to the question "can (hostname) subdomains have an underscore" are correct answers to this question.
对于非 IDN 域名,每个域名允许的字符数
RFC 1035 是:
az
AZ
0-9
-
.
– 如果是子域的一部分这是完整的定义:
特别是关于上/下域,域名是不区分大小写。以下是 RFC 1035 中有关此内容的一些内容:
此答案解决了非 IDN域名所允许的问题,并且不 定义 Web 浏览器、客户端应用程序或应用程序服务器的行为。如果您设置了通配符 (
*
) 将流量路由到某处,则子域可能包含超出a-zA-Z0-9- 集合的字符。
。For non-IDN domain names, the allowed characters per
RFC 1035 are:
a-z
A-Z
0-9
-
.
– if part of a subdomainHere's the full definition:
Specifically regarding upper/lower, domain names are case-insensitive. Here's a bit from RFC 1035 about that:
This answer addresses what is allowed for non-IDN domain names, and does not define behavior for a web browser, client application, or application server. If you've set up a wildcard (
*
) to route traffic somewhere, it's possible for a subdomain to contain characters beyond the set ofa-zA-Z0-9-.
.