子域中允许使用哪些字符?

发布于 2024-11-30 02:04:39 字数 153 浏览 0 评论 0原文

子域中允许使用哪些字符?

示例:对于 someSub.example.comsomeSub 部分。

我知道您可以使用字母、数字和连字符,但是其他字符呢?可以使用_(下划线)吗?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

来日方长 2024-12-07 02:04:39

字母(重音 à 除外)、数字 0-9 和连字符。

http://en.wikipedia.org/wiki/Domain_name
摘抄:
域名中可以使用的有效字符有:

a-z
0-9
- but not as a starting or ending character
. as a separator for the textual portions of a domain name

来自 https://www.rfc-editor。组织/rfc/rfc1035

DNS 中的各种对象和参数都有大小限制。他们是
下面列出。有些可以很容易改变,有些则更容易改变
基础。

labels          63 octets or less
names           255 octets or less
TTL             positive values of a signed 32 bit number.
UDP messages    512 octets or less

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:

a-z
0-9
- but not as a starting or ending character
. as a separator for the textual portions of a domain name

From https://www.rfc-editor.org/rfc/rfc1035

Various objects and parameters in the DNS have size limits. They are
listed below. Some could be easily changed, others are more
fundamental.

labels          63 octets or less
names           255 octets or less
TTL             positive values of a signed 32 bit number.
UDP messages    512 octets or less
瑾兮 2024-12-07 02:04:39

根据此页面,一些顶级域现在允许本地化字符(不仅仅是 az)。

--------------------------------------------------------------------------------
| Top Level Domain |                    Allowed Characters                     |
--------------------------------------------------------------------------------
| .no              | áàäčçđéèêŋńñóòôöšŧüžæøå                                   |
| .se              | àáäåæçèéêëìíîïðñòóôöøùúüýþćčđěłńŋřśšţŧźžǎǐǒǔǥǧǩǯəʒ, plus Hebrew
| .dk              | äåæéöøü
| .is              | áéýúíóþæöð
| .it              | àâäèéêëìîïòôöùûüæœçÿ
| .fr              | àáâãäåæçèéêëìíîïñòóôõöùúûüýÿœ
| .nu              | àáâäåāæçèéêëēìíîïīðñŋòóôõöøōùúûüūýþÿ
| .be              | àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿœ
| .de              | àáâãäåāăąæçćĉċčďđèéêëēĕėęěŋðĝğġģĥħìíîïĩīĭįıĵķĸĺļľł
|                  | ñńņňòóôõöøōŏőœŕŗřśŝşšţťŧþùúûüũūŭůűųŵýÿŷźżž
| .as              | Same as .de
| .com             | Same as .de, plus Greek, Cyrillic, Chinese, Korean, etc.
| .net             | Same as .de, plus Greek, Cyrillic, Chinese, Korean, etc.
| .org             | áäåāąæćčéēėęģíīįķļłñńņðóöøōőŗśšúüūűųýźżžþ plus Cyrillic and Korean
| .info            | áäåāąæćčéēėęģíīįķļłńņðóöøōőŗśšúüūűųýźżžþ plus Korean
| .biz             | àáäåæéêíðñòóôöøúüýþ
--------------------------------------------------------------------------------

所以,看起来我们需要回到正则表达式的绘图板上。

According to this page, some top level domains now allow localized characters (not just a-z).

--------------------------------------------------------------------------------
| Top Level Domain |                    Allowed Characters                     |
--------------------------------------------------------------------------------
| .no              | áàäčçđéèêŋńñóòôöšŧüžæøå                                   |
| .se              | àáäåæçèéêëìíîïðñòóôöøùúüýþćčđěłńŋřśšţŧźžǎǐǒǔǥǧǩǯəʒ, plus Hebrew
| .dk              | äåæéöøü
| .is              | áéýúíóþæöð
| .it              | àâäèéêëìîïòôöùûüæœçÿ
| .fr              | àáâãäåæçèéêëìíîïñòóôõöùúûüýÿœ
| .nu              | àáâäåāæçèéêëēìíîïīðñŋòóôõöøōùúûüūýþÿ
| .be              | àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿœ
| .de              | àáâãäåāăąæçćĉċčďđèéêëēĕėęěŋðĝğġģĥħìíîïĩīĭįıĵķĸĺļľł
|                  | ñńņňòóôõöøōŏőœŕŗřśŝşšţťŧþùúûüũūŭůűųŵýÿŷźżž
| .as              | Same as .de
| .com             | Same as .de, plus Greek, Cyrillic, Chinese, Korean, etc.
| .net             | Same as .de, plus Greek, Cyrillic, Chinese, Korean, etc.
| .org             | áäåāąæćčéēėęģíīįķļłñńņðóöøōőŗśšúüūűųýźżžþ plus Cyrillic and Korean
| .info            | áäåāąæćčéēėęģíīįķļłńņðóöøōőŗśšúüūűųýźżžþ plus Korean
| .biz             | àáäåæéêíðñòóôöøúüýþ
--------------------------------------------------------------------------------

So, looks like we need to go back to the drawing board on that regex.

谜兔 2024-12-07 02:04:39

从技术上讲,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.

一场信仰旅途 2024-12-07 02:04:39

讽刺的是,这个问题的其他答案是“主机名或主域的合法字符是什么”问题的正确答案,而 问题“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.

彩扇题诗 2024-12-07 02:04:39

对于非 IDN 域名,每个域名允许的字符数
RFC 1035 是:

  • az
  • AZ
  • 0-9
  • -
  • . – 如果是子域的一部分

这是完整的定义:

<domain> ::= <subdomain> | " "
<subdomain> ::= <label> | <subdomain> "." <label>
<label> ::= <letter> [ [ <ldh-str> ] <let-dig> ]
<ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>
<let-dig-hyp> ::= <let-dig> | "-"
<let-dig> ::= <letter> | <digit>
<letter> ::= any one of the 52 alphabetic characters A through Z in upper case and a through z in lower case
<digit> ::= any one of the ten digits 0 through 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 subdomain

Here's the full definition:

<domain> ::= <subdomain> | " "
<subdomain> ::= <label> | <subdomain> "." <label>
<label> ::= <letter> [ [ <ldh-str> ] <let-dig> ]
<ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>
<let-dig-hyp> ::= <let-dig> | "-"
<let-dig> ::= <letter> | <digit>
<letter> ::= any one of the 52 alphabetic characters A through Z in upper case and a through z in lower case
<digit> ::= any one of the ten digits 0 through 9

Specifically regarding upper/lower, domain names are case-insensitive. Here's a bit from RFC 1035 about that:

Note that while upper and lower case letters are allowed in domain names, no significance is attached to the case. That is, two names with the same spelling but different case are to be treated as if identical.

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 of a-zA-Z0-9-..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文