9

I looked up couple of questions on SO, which seem to suggest that two continuous hyphens (e.g. my--website.com) are not allowed but when I search for same domain name on http://www.register.com/index.rcmx, it gladly accepts the name while rejects non valid domain names like my#website.com.
Validation for URL/Domain using Regex? (Rails)

4 Answers 4

13

It's legal in a domain name, and required for internationalised domain names (IDNs) which when converted from Unicode to ASCII end up prefixed with xn--

2
  • 1
    This has rules which would allow double dashes: faqs.org/rfcs/rfc1035.html
    – Lee Meador
    Commented May 9, 2013 at 18:21
  • 2
    RFC1035 is not the last word on legal domain names and host names - there's more in RFC 2181.
    – Alnitak
    Commented May 9, 2013 at 18:25
10

In general double hyphens are allowed. However, in your specific example, it should not be possible, because they may not occur on the third and fourth position except when writing IDN labels in their xn-- notation. See the following section from RFC 5891:

4.2.3.1. Hyphen Restrictions

The Unicode string MUST NOT contain "--" (two consecutive hyphens) in the third and fourth character positions and MUST NOT start or end with a "-" (hyphen).

4
  • Every third and fourth, or just the third and fourth?
    – Pacerier
    Commented Jan 3, 2020 at 12:15
  • Just the third and fourth character. Commented Jan 9, 2020 at 8:26
  • And only for INTERNATIONALIZED DNS, e.g. xn--j1ail.xn--p1ai which is the ASCII version of кто.рф Commented Oct 5, 2020 at 22:01
  • Double hyphens in the 3rd and 4th positions are not permitted in an Internationalized Domain Name (IDN) per RFC5891, but an IDN is not a "real" domain name in the sense of RFC1034/1035 and DNS, but rather a string that must be converted to an encoded form before usage in DNS. Thus, a registrar must not allow the entry of кт--о.рф because the presence of Unicode characters indicates an IDN string, and the position (3,4) hyphens violates RFC5891; however, DNS clients must allow xx--xxxx.com as a domain as permitted by RFC1034.
    – ozmo
    Commented Dec 5 at 23:32
3

Some TLDs allow as many consecutive dashes as you want, others seem to have specific rules about their positioning.

This is a working website: l-------------------------------------------------------------l.tk (mirror)

The universal rules are:

  1. Not in the 3rd and 4th position, except as part of an IDN
  2. Not at the beginning or end

Nothing else can be counted on unless you thoroughly test each individual TLD.

2

It must be "allowed", regardless of the answers here, because https://hp--community.force.com exists. However, perhaps that's only okay because it's a subdomain of a registered domain, and not a registered domain in itself.

1
  • 2
    I'm quite sure the rules for subdomains are different - and less restrictive - than the ones for domain names. Commented Jan 9, 2020 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.