Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the definition of an absolute URL (fully qualified?)

There are (at least) three ways to link to a resource:

  1. href="foo/bar.html"
  2. href="/foo/bar.html"
  3. href="http://example.com/foo/bar.html"

The first is a "relative url", no problem. But I've seen (2) and (3) both referred to as an "absolute url". Which is correctly termed an "absolute url", and what is the proper name of the other?

(Bonus points for references to relevant standards or other official documentation.)

like image 864
Scott Stafford Avatar asked Jul 01 '13 14:07

Scott Stafford


People also ask

What is a absolute URL?

An absolute URL contains all the information necessary to locate a resource. A relative URL locates a resource using an absolute URL as a starting point. In effect, the "complete URL" of the target is specified by concatenating the absolute and relative URLs.

What is a fully qualified link?

A fully-qualified domain name (FQDN) is that portion of an Internet Uniform Resource Locator (URL) that fully identifies the server program that an Internet request is addressed to.

How do you make an absolute URL?

If you prefix the URL with // it will be treated as an absolute one. For example: <a href="//google.com">Google</a> . Keep in mind this will use the same protocol the page is being served with (e.g. if your page's URL is https://path/to/page the resulting URL will be https://google.com ).

When would you use an absolute URL?

Linking with absolute URLs The domain is the name of the website. For example, the domain name of Indiana University's central web server is www.indiana.edu . The path includes directory and file information. You must use absolute URLs when referring to links on different servers.


3 Answers

RFC 3986 defines Uniform Resource Identifiers.

A relative reference that begins with a single slash character is
termed an absolute-path reference. A relative reference that does
not begin with a slash character is termed a relative-path reference.

  1. href="foo/bar.html" is a relative reference, specifically a relative-path reference.
  2. href="/foo/bar.html" is a relative reference with an absolute path
  3. href="http://example.com/foo/bar.html" is an absolute URI
  4. href="//example.com/foo/bar.html" is a network-path reference

A relative reference that begins with two slash characters is termed a network-path reference; such references are rarely used.

like image 54
Jacob Krall Avatar answered Oct 13 '22 11:10

Jacob Krall


"Absolute URLs contain a great deal of information which may already be known from the context of the base document's retrieval, including the scheme, network location, and parts of the URL path."

https://www.rfc-editor.org/rfc/rfc1808

The number (2) is an absolute path, the (3) is an absolute URL.

like image 31
Lorenzo Marcon Avatar answered Oct 13 '22 12:10

Lorenzo Marcon


I like the W3's description found here:

A URL is an absolute URL if resolving it results in the same output regardless of what it is resolved relative to, and that output is not a failure.

It doesn't bring up scheme, path, or any other concepts like that, but basically just says that the same input always brings the same output. You can only say that about #3.

I wouldn't get too caught up in the technicalities though - #2 is still absolute if your universe is the website. Also something like //example.com/foo/bar.html is absolute if your universe is the scheme. I think the word "absolute" in those cases is still meaningful from a developer's perspective.

like image 2
Joe Enos Avatar answered Oct 13 '22 13:10

Joe Enos