What's the difference between a URL such as “a

2020-02-15 08:08发布

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条回答
姐就是有狂的资本
2楼-- · 2020-02-15 08:44

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)
查看更多
登录 后发表回答