开发者

Do web page URLs always have a subdomain

开发者 https://www.devze.com 2023-01-31 14:22 出处:网络
I\'m writing a url parser. Do url\'s I\'d type into an internet browser always have a subDomain? I mean, will there alwa开发者_开发技巧ys be something where www is in this example, and is there alway

I'm writing a url parser. Do url's I'd type into an internet browser always have a subDomain?

I mean, will there alwa开发者_开发技巧ys be something where www is in this example, and is there always a '.' between the sub-domain and the domain?

http://www.domain.com/path/page.htm

Thanks.


No they don't.

If you go to http://example.com, you will see it doesn't redirect to a www subdomain.

And yes, there will always be a . between the parts of the hierarchy.


There is tons of various possibilities, you can find :

  • http://www.example.com/path/paeg.html?query=string
  • http://example.com/path/paeg.html?query=string
  • http://sub.www.example.com/path/paeg.html?query=string
  • http://user:password@www.example.com/path/paeg.html?query=string
  • http://user@www.example.com/path/paeg.html?query=string
  • http://www.example.com:4040/path/paeg.html?query=string
  • http://user@www.example.com:4040/path/paeg.html?query=string
  • etc ...

So NO, there is not necessary a subdomain in the url. And there isn't a '.' between the sub-domain and the domain, when the sub-domain is empty.

If you are using PHP, you need to know that it already exists similar parser, like parse_url : http://fr.php.net/parse_url

And I'm sure there is also a parser in every (major) languages

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号