URI vs URL

I’ve had issues with this book I’m reading and the author’s use of relative and absolute paths and includes. (Not to mention lots of crappy coding practices.)

The book mention defining constants for various paths. (This part makes sense so I can easily go from my development environment to my web hosting environment.)

But I don’t understand what the author says here…

define(‘BASE_URI’, ‘/path/to/Web/parent/folder/’);
define(‘BASE_URI’, ‘www.example.com/’);

1.) So what is the difference between “URI” and “URL”??

2.) I don’t see where and why he would use each.

3.) Aren’t those two paths supposed to be the same? (I mean your main URL is your “web root” when you host a website, right?)

That is what I’m all confused about…

TomTees

TT,

A URL is the full location you request of your browser.

http://domain.tld/path/to/filename.ext?a=b

where http:// is the protocol

domain.tld is the domain

/ is a separator (it used to be considered part of the URI)

path/to/filename.ext is the URI with path/to/ being the path (directories under DocumentRoot)

filename.ext is the filename ({REQUEST_FILENAME})

? is a separator, a RESERVED character

a=b is the query string where

a is the key and

b is the value.

May I refer you to Sir Tim Berners-Lee’s treatise on the allowed characters in the URI:

Uniform Resource Identifiers (URI): Generic Syntax

Regards,

DK

A URL is a URI. Sounds strange I know…
But maybe this diagram will help make it a little clearer: http://en.wikipedia.org/wiki/File:URI_Venn_Diagram.svg

Sadly the RFCs are more of a PITA to read versus something like Wikipedia.

That was very informative!!

Thank you!

TomTees

Not according to what David wrote.

Based on his description of things, it would be the other way around.

TomTees

A URL is subset a URI. URI defines the base syntax.

From the RFC document linked above by David:
http://www.ietf.org/rfc/rfc2396.txt

A URI can be further classified as a locator, a name, or both. The
term “Uniform Resource Locator” (URL) refers to the subset of URI
that identify resources via a representation of their primary access
mechanism (e.g., their network “location”), rather than identifying
the resource by name or by some other attribute(s) of that resource.
The term “Uniform Resource Name” (URN) refers to the subset of URI
that are required to remain globally unique and persistent even when
the resource ceases to exist or becomes unavailable.