URI、URL、URN的关系

489 阅读1分钟

URI

URI(统一资源标识符) 是 Uniform Resource Identifier的缩写,即是一个用于标识某一互联网资源名称的字符串。

URI的基本格式如下图:

                    hierarchical part
        ┌───────────────────┴─────────────────────┐
                    authority               path
        ┌───────────────┴───────────────┐┌───┴────┐
  abc://username:password@example.com:123/path/data?key=value&key2=value2#fragid1
  └┬┘   └───────┬───────┘ └────┬────┘ └┬┘           └─────────┬─────────┘ └──┬──┘
scheme  user information     host     port                  query         fragment

  urn:example:mammal:monotreme:echidna
  └┬┘ └──────────────┬───────────────┘
scheme              path

URI基本格式

URL、URN

URL(Uniform Resource Locator 统一资源定位符)、URN(Uniform Resource Name 统一资源名称)都是URI的子集,两者都是用来表示资源的字符串,只是URL带上了域名或ip,直接指出了资源所在的具体位置,而URN只是一串字符串,需要另外的解析最后才能得到资源的具体位置。

URL: juejin.cn/post/684490…

URN:ISBN:1-930110-59-6

URI、URL、URN关系图

参考文章

URI、URL 和 URN 的区别