What is the difference between URL and URI?

Asked

Viewed 32,104 times

75

What is URL? What is URI? Are they synonymous? In general people almost always use URL, are they the same thing? Is there anything else related?

  • 4

    URI = URL or URN, that is, the URL is a category of URI. So every URL is a URI, and otherwise it is not true, because a URI can be a URN.

1 answer

81


URI or Uniform Identifier of Resources or Uniform Resource Identifier (in English) is a compact character string used to identify or name a resource on the Internet. The main purpose of this identification is to allow interaction with representations of the resource through a network, typically the World Network, using specific protocols. Uris are identified in groups defining a specific syntax and associated protocols.

Source: Wikipedia

It is a widespread way of calling both Urls and Urns.

It is rare to use the term URN, especially in programming.

A Uniform Name of Appeal, URN (in English Uniform Resource Name) is a type of URI that uses the URN Scheme and aims to uniquely identify the resource, persistently and independently of its location.

Source: Wikipedia

An example of URN would be urn:lex:br:federal:lei:2008-06-19;11705. This is a standardized way to reference this law. The same goes for books, metadata and other unique identifiers.

This identifier lives inside a namespace.

What matters most to programmers is the URL since we need to identify in addition to a unique name, the location of that resource.

A URL (of Uniform Resource Locator), in Portuguese Standard Resource Finder, is the address of a resource (such as a file, printer, etc.), available on a network; be it the Internet, or even a corporate network such as an intranet.

A full URL has the following structure:

esquema://domínio:porta/caminho/recurso?querystring#fragmento
  • schema, or protocol, may be HTTP, HTTPS, FTP, among others.
  • domain, or machine, means the server that provides the designated document or resource.
  • port, or port, is the logical point at which one can make the connection to the server (optional).
  • path specifies the location (usually in a file system) where the - resource is inside the server.
  • query string is a set of parameters to be sent to the server, used to locate, filter, or even create the resource (optional).
  • fragment identifier refers to a specific part or position within the resource (optional).

The schema tells you how to connect, the domain specifies where to connect, and the rest specifies what is being requested.

Example:

http://www.w3.org/Addressing/URL/uri-spec.html

the protocol is the HTTP, the server is designated by www.w3.org and the resource - in this case the file uri-spec.html - is in Addressing/URL/. The door, omitted, falls on the protocol standard (in case, 80) and there is no query string or fragment identifier.

Source: Wikipedia

Another example of URL:

mailto:[email protected]

You have the protocol mailto: the identifier nomedealguem and where it is located example.com.

Additional information

Every URL is a URI but the opposite is not true.

We can say that an URN is a person and a URL is a full address.

I have seen some people use a person’s name as an example of URN. This is wrong. That person’s document would be more appropriate as that person’s identifier. The name is not unique, the document is, provided it is specified appropriately.

Have you noticed that there is a discrepancy in the translation provided by Wikipedia between URL and URI? I don’t know if there is a formal source that indicates which one is correct (do you know?) but I think that the "uniform" should be used as a translation of all these terms. " Pattern" seems strange to me for the case (but will try to change on pt.wikipedia to see what happens to it :)). URI

Muddle

Pay attention to two frequent confusions:

  • URL is a tracker and not a location.
  • Therefore it is masculine and not feminine as people usually use. So we should use the URL.

No one will fight you for using URL, but this term is considered more informal. In general every time you are using the term URL you should actually use URI. After all when you place an address of a resource you are placing the location of a resource with a unique identifier, you use the URL and the URN, so you are referencing a URI and its use is formally recommended.

Just because they don’t understand these distinctions people find it strange that XML has Uris (and they actually think they have Urls). I lost count of how many programmers complain that they would not like the file to need access to the internet because it has an address web inside it. What’s in the namespace XML is a URI. That is, it is only an identifier and it happens to also be an address web, but it is only a unique way to identify how that namespace. It serves as a reference, but access to the Internet will only be necessary if a human wants to know more about it, no application accesses the Internet because of that unless the programmer wishes.

More references

More information can be read on Wikipedia article in English. The links there, especially for other articles of Wikipedia itself, are very interesting and can complete an information that does not seem at first but is valuable.

Before supposing anything it is better to understand well the meaning of each thing in all its details.

  • That one "on the Internet" of the stretch "URI [...] is a compact string used to identify or name a resource on the Internet" of Wikipedia, is incorrect right, and does not have also in the English version. There they say only that is used in networks, usually the World Wide Web. I know you quoted what was there, but suddenly it was good to put a warning to make clear!

  • @Pedrogaspar na pt is exactly like this, na en is a little ambiguous or incomplete.

  • I tried to correct "You have the Procolo mailto: ..." to "You have the protocol mailto: ..." but Stack Overflow prevented editing by displaying the following message: "Edits must be at least 6 characters long. There’s more to improve this post?"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.