What's the difference between a URL such as “a.b.example” instead of “b.example/a”?

若如初见. 提交于 2019-12-18 09:52:25

问题


Why do some websites I see have a URL in the form a.b.example, and others are in the form of b.example/a?

For example, why is it gist.github.com instead of github.com/gist?


回答1:


These are different components. See section 3 of the URI standard for a list of components and their definitions.

https://gist.github.com/
  • The authority (or more specifically, the host) is gist.github.com.
  • The path is /.
https://github.com/gist
  • The authority (or more specifically, the host) is github.com.
  • The path is /gist.

As https://gist.github.com/ would typically also have paths like the second URI (e.g., https://gist.github.com/foobar), I guess you are primarily interested in the authority component.

In your examples, the DNS gets used, i.e., these are domains, which consist of labels, separated by .:

  • gist is a third-level domain (aka. subdomain)
  • github is a second-level domain
  • com is a top-level domain (TLD)

The top level controls the second level, the second level controls the third level, and so on. So if you buy the domain name github.com, you typically have control about all of its third-level domains (and fourth-level, etc.).

It’s up to the webmaster which kind of URI design gets used, and the decision can depend on many different factors: what is technically possible for them and the systems they use, usability (example), SEO (example), etc. A common reason for using different host names (domains) is that they can be easily hosted on different servers.

Examples:

  • eBay uses different (top-level) domains for each of their localized sites (e.g., http://www.ebay.de/ for Germany, http://www.ebay.it/ for Italy)
  • Tumblr uses a subdomain for each of their users (e.g., http://alice.tumblr.com/ for Alice, http://bob.tumblr.com/ for Bob)
  • Twitter uses a path segment for each of their users (e.g., https://twitter.com/alice for Alice, https://twitter.com/bob for Bob)
  • Wikipedia uses subdomains for different languages (e.g., https://en.wikipedia.org/ for English, https://fr.wikipedia.org/ for French)


来源:https://stackoverflow.com/questions/39542139/whats-the-difference-between-a-url-such-as-a-b-example-instead-of-b-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!