Uniform Resource Locators (URLs)
One of the most important things to grasp when working on the Web is the format for URLs. A URL is basically an address on the Web, identifying each document uniquely (for example, http://www.oreilly.com/products.html). Since URLs are so fundamental to the Web, we discuss them here in a little detail. The simple syntax for a URL is:
http://host/path
- host
The host to connect to: www.oreilly.com or www.google.com. (While many web servers run on hosts beginning with www, the www prefix is just a convention.)
- path
The document requested on that server. This is not the same as the filesystem path, as its root is defined by the server.
Most URLs follow this simple syntax. A more generalized syntax, however, is:
scheme://host/path/extra-path-info?query-info
- scheme
The protocol that connects to the site. For web sites, the scheme is
http; for FTP, the scheme isftp.- extra-path-info and query-info
Optional information used by CGI programs. See Chapter 12.
HTML documents also often use a “shorthand” for linking to other documents on the same server, called a relative URL. An example of a relative URL is images/webnut.gif. The browser knows to translate this into complete URL syntax before sending the request. For example, if http://www.oreilly.com/books/webnut.html contains a reference to images/webnut.gif, the browser reconstructs the relative URL as a full (or absolute) URL, http://www.oreilly.com/books/images/webnut.gif, and requests that document ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access