tags:

views:

416

answers:

4
+6  Q: 

Types of URLs

1) Absolute
http://www.example.com/images/icons.png

2) Relative
../images/icons.png

3) ???
/images/icons.png

4) ???
//www.example.com/images/icons.png

Do URL types 3 and 4 have a name? One place I've seen type 4 being used is at slashdot.

+2  A: 

Type three is root-relative.

Dunno about 4.

Tony k
Scheme-relative? :-P
Chris Jester-Young
protocol-agnostic?
sjstrutt
+6  A: 

number 3 is also considered relative. number 4 is absolute, but lacks the protocol. This is useful, if you want to be able to access the same URL using HTTP and HTTPS.

Absolute URLs specify the location of a Web page in full, and work identically no matter where in the world you are.

Relative URLs are context-sensitive, giving a path with respect to your current location.

Jose Basilio
Yes, I think that's about right.
Cerebrus
+7  A: 
  1. Absolute http://www.example.com/images/icons.png
  2. Document-Relative ../images/icons.png
  3. Root-Relative /images/icons.png
  4. Protocol-Relative //www.example.com/images/icons.png

For #4, I've also often called them "Protocol-Agnostic"

sjstrutt
this answer might look good, but AFAIK it's all just made up
Alnitak
+8  A: 

Type 1 is just a "URI" (sometimes called an "absolute URI").

For types 2, 3 and 4 the definitive answers are in RFC 3986, section 4.2.

They are all "relative references", but according to the RFC are qualified thus:

  • ../images/icons.png - relative path reference
  • /images/icons.png - absolute path reference
  • //.../icons.png - network path reference
Alnitak
+1 for actually quoting a source
Joachim Sauer