URL 实际上是什么
URL 就是你所请求的地址。它看起来像一长串字符,但其实是几个带标签的部分缝接而成。把它拆开来看:
https://shop.example.com/products/shoes?size=10
https scheme — how to talk (use HTTPS, the secure way)
shop.example.com host — which server to talk to
/products/shoes path — which page or thing you want from it
?size=10 query — extra details ("the size-10 ones")
像读一个倒过来的邮政地址那样读它:
- scheme(
https)是协议——对话的规则。如今几乎总是https。 - host(
shop.example.com)指明要联系哪一台服务器。 - path(
/products/shoes)指明你想要那台服务器上的哪样东西。 - 可选的 query(
?size=10)携带额外参数,比如筛选条件或搜索词。
当有人说“端点”或“路由”时,他们几乎总是指某台特定 host 上某个特定 path。那些吓人的词的全部含义也就是这些。