Django URLValidator will raise a validation error for this website URL because of the underscore:

http://beauharnois_bupa.tripod.com/

From what I've read some says that it's not a valid domain name, some say it is and the RFCs seems to say that it's legal in the subdomain label but not in the hostname.

My guess is that it is legal in the subdomain label since the website mentioned above works..

Who's right ?

  • It's an illegal character according to most standards, but every browser supports it and there are some major sites using them. So, for practical purposes, they should be supported by any parser/validator meant to work with real world URLs. – smola Jan 13 '14 at 23:36
up vote 5 down vote accepted

Underscores are not valid characters, even in subdomains, so it will be marked as invalid. However, some sites that dynamically route requests based on a subdomain component do allow underscores, even though they're technically an invalid character. So you might be able to navigate to the URL, even though it's technically not valid.

RFC 1035 discusses the structure of a domain name.

according to Can (hostname) subdomains have an underscore "_" in it? it should be legal.

It is perfectly legal to have an underscore in a domain name. Let me quote the standard, RFC 2181, section 11, "Name syntax":

  • 1
    pls see the comments for this answer as well, RFC2181 is for the domains, not for the hostnames. – Walty Yeung Dec 10 '15 at 9:53
  • @WaltyYeung and? We are talking domains here, not hostnames. Underscore should then be valid. – dangonfast May 7 at 6:12

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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