views:

45

answers:

2

When validating URLs, I was wondering if the root could be setup like this:

http://my.great.web.site.I.rule.com/

I guess the real question is, if someone wanted to buy a .com with the name "some.site", would the above example be possible?

I was thinking something like that was out of the ordinary, and that the maximum would be something like this:

http://subdomain.mysite.com/

I might be thinking about this wrong, but I have very little knowledge of url structures and am trying to learn as much as I can.

Just wondering, because you could get a heck of a lot more precise with a regex expression like this (assuming periods cannot be used in domain/subdoamin names):

(https?:\/\/)([a-z0-9_-]{1,63}\.){1,2}([a-z]{2,8}){1}\/

then you could with this (assuming periods can be used in domain/subdomain names):

(https?:\/\/)([a-z0-9_-]{1,63}\.)\/

Any thoughts, or is this just ridiculous?

+1  A: 

Regarding the urls, you can have (in theory) up to 127 domains (counting the top level domain name .com), as long as the domain exceed 255 characters and each sub domain is less than 64 characters.

Yacoby
Do you mean that you can have 125 subdomains less than 64 characters, 1 top level less than 255 characters, and a .com (or whatever)? Or do you mean the whole thing cannot be greater than 255 characters (excluding the http://)?
bschaeffer
The whole thing cannot be greater than 255 characters
Yacoby
+2  A: 

Wikipedia has good descriptions of URI schemas with links to all the relevant RFCs and Domain Names.

One note about your regex, you should also consider including port numbers when servers are hosted at non-default ports, e.g.

http://typicaltomcat.com:8080/

Edit: If you are looking for a regex to match URLs, there is interesting article on a liberal URL matcher.

John Paulett
Schemas.... thats the word I was looking for! Thanks for the link, too!
bschaeffer
I just saw you're edit and I too saw that article. I kind of stole some of the ideas in the DF pattern and used them as my own, and have also been referencing that schema document you linked to. Thanks, again.
bschaeffer