Relative URLs

The general format of a simple URL:

scheme:// host /path

http://www.website.com/catalog/usa/texas/dallas/products.html

Parts:

Examples of Full URLs:

Examples of Relative URLs:

Our imaginary web site:


In the products.html file, if we wanted:

Solution #1:

Problems with Solution #1

Solution #2:

Problems with solution #2

Solution #3 - The Best Approach



These files and directories are at the same levels:

As an additional exercise:

To link to the texaslocations.html from each of the directories the relative URL would be:

/ catalog/usa/texas/texaslocations.html
images ../catalog/usa/texas/texaslocations.html
catalog usa/texas/texaslocations.html
usa texas/texaslocations.html
texas texaslocations.html
dallas ../texaslocations.html

For more information:


Check out the W3C's RFC at http://www.w3c.org/Addressing/rfc1808.txt