URI,URL和URN有什么区别? [英] What is the difference between a URI, a URL and a URN?

查看:287
本文介绍了URI,URL和URN有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

人们谈论网址 URI URN ,就好像它们是不同的东西,但它们看起来一样肉眼。

People talk about URLs, URIs and URNs as if they're different things, but they look the same to the naked eye.

它们之间有什么区别?

推荐答案

来自 RFC 3986


URI可以进一步分类为定位器,名称或两者。
术语统一资源定位符(URL)是指URI
的子集,除了标识资源之外,还提供
的方法,通过描述其主要访问机制来定位资源
(例如,其网络位置)。历史上使用术语统一资源名称
(URN)来引用
urn方案[RFC2141]下的两个URI,这些URI需要保持全局唯一
和持久性即使资源不再存在或变为
不可用,以及任何其他具有名称属性的URI。

A URI can be further classified as a locator, a name, or both. The term "Uniform Resource Locator" (URL) refers to the subset of URIs that, in addition to identifying a resource, provide a means of locating the resource by describing its primary access mechanism (e.g., its network "location"). The term "Uniform Resource Name" (URN) has been used historically to refer to both URIs under the "urn" scheme [RFC2141], which are required to remain globally unique and persistent even when the resource ceases to exist or becomes unavailable, and to any other URI with the properties of a name.

因此所有URL都是URI(实际上并不完全 - 见下文),并且所有URN都是URI - 但URN和URL是不同的,因此您不能说所有URI都是URL。

So all URLs are URIs (actually not quite - see below), and all URNs are URIs - but URNs and URLs are different, so you can't say that all URIs are URLs.

编辑:我以前认为所有网址都是有效的URI,但根据评论:

I had previously thought that all URLs are valid URIs, but as per comments:


所有网址都是URI。这取决于RFC的解释。例如,在Java中,URI解析器不喜欢 [] ,这是因为规范说不应该和不是不会。

Not "all URLs are URIs". It depends on the interpretation of the RFC. For example in Java the URI parser does not like [ or ] and that's because the spec says "should not" and not "shall not".

不幸的是,这使得水域更加混乱。

So that muddies the waters further, unfortunately.

如果您尚未阅读 Roger Pate的答案,我建议您也这样做。

If you haven't already read Roger Pate's answer, I'd advise doing so as well.

这篇关于URI,URL和URN有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆