What is the difference between a URI, a URL and a URN?

前端 未结 30 1771
小蘑菇
小蘑菇 2020-11-22 02:18

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

W

30条回答
  •  一整个雨季
    2020-11-22 02:43

    This is one of the most confusing and possibly irrelevant topics I've encountered as a web professional.

    As I understand it, a URI is a description of something, following an accepted format, that can define both or either the unique name (identification) of something and its location.

    There are two basic subsets - URLs, which define location (especially to a browser trying to look up a webpage) and URNs, which define the unique name of something.

    I tend to think of URNs as being similar to GUIDs. They are simply a standardized methodology for providing unique names for things. As in the namespace declarative that uses a company's name - it's not like there is a resource sitting on a server somewhere to correspond to that line of text - it simply uniquely identifies something.

    I also tend to completely avoid the term URI and discuss things only in terms of URL or URN as appropriate, because it causes so much confusion. The question we should really try answering for people isn't so much the semantics, but how to identify when encountering the terms whether or not there is any practical difference in them that will change the approach to a programming situation. For example, if someone corrects me in conversation and says, "oh, that's not a URL it's a URI" I know they're full of it. If someone says "we're using a URN to define the resource" I'm more likely to understand we are only naming it uniquely, not locating it on a server.

    If I'm way off base - please let me know!

提交回复
热议问题