views:

473

answers:

5

I am writing some documentation and I have a little vocabulary problem:

  1. http://www.somedomain.com/en/public/img/logo.gif is called an "absolute" url, right?
  2. ../../public/img/logo.gif is called a "relative" url, right?
  3. so how do you call this: /en/public/img/logo.gif ?

Is it also considered an "absolute url", although without the protocol and domain parts?

Or is it considered a relative url, but relative to the root of the domain?

I googled a bit and some people categorize this as absolute, and others as relative.

What should I call it? A "semi-absolute url"? Or "semi-relative"? Is there another word?

+3  A: 
  1. http://www.somedomain.com/en/public/img/logo.gif

-Fully qualified

  1. ../../public/img/logo.gif

-Relative

  1. /en/public/img/logo.gif

-Absolute

jvenema
You’re wrong. The examples 2 and 3 are not relative and absolute URLs respectively but just relative and absolute URL *paths*. So they are both just relative URLs.
Gumbo
Maybe so, but in day-to-day terms, everyone uses the description I've just given :)
jvenema
+1  A: 

It is sometimes called a virtual url, for example in SSI:

<!--#include virtual = "/lib/functions.js" -->
Guffa
+17  A: 

Here are the URL components:

http://www.example.com/en/public/img/logo.gif
\__/   \_____________/\_____________________/
 #1     #2             #3
  1. scheme/protocol
  2. host
  3. path

A URL is called an absolute URL if it begins with the scheme and scheme specific part (here // after http:). Anything else is a relative URL.

A URL path is called an absolute URL path if it begins with a /. Any other URL path is called a relative URL path.

Thus:

  • http://www.example.com/en/public/img/logo.gif is a absolute URL,
  • ../../public/img/logo.gif is a relative URL with a relative URL path and
  • /en/public/img/logo.gif is a relative URL with an absolute URL path.


Note: The current definition of URI (RFC 3986) is different from the old URL definition (RFC 1738 and RFC 1808).

The three examples with URI terms:

  • http://www.example.com/en/public/img/logo.gif is a URI,
  • ../../public/img/logo.gif is a relative reference with just a relative path and
  • /en/public/img/logo.gif is a relative reference with just an absolute path.
Gumbo
A: 

Keep in mind just how many segments of the URL can be omited, making them relative (note: its all of them, just about). These are all valid URLs:

  • http://foo.com/bar?baz
  • ?qoo
  • /bar2
  • dat/sly
  • ://auth.foo.com (most people are surprised by this one! Will use http or https, depending on the current resource)
  • #anchor
ironfroggy
Your fifth example should be `//auth.foo.com` without the colon.
Gumbo
A: 

I have seen it called a root relative url. Try searching google using that term.

kevinh