ToC ~ Up ~ Prev ~ Next ~ Index Introduction to HTML
Last Update: 5 January 1998

8. Uniform Resource Locators (URLs)

URLs, or Uniform Resource Locators, are the method by which documents or data are addressed in the World Wide Web. The URL contains the following information:

URLs are more sophisticated than this brief introduction would imply. For more detail, have a look at the URL overview document, found at the URL: http://www.w3.org/hypertext/WWW/Addressing/URL/Overview.html.

8.0 Structure of an URL

The following is an outline of the most common form of a URL:

    http://www.address.edu:1234/path/subdir/file.ext
|        |                |    |                    |
|service |                |    |                    |
         |____ host ______|    |                    |
                          |    |                    |
                          |port|                    |
                               |      file and      |
                               |_ resource details _|

8.0.1 Service

The above figure gives a general outline of URL structure. This outline if followed by most, but not all, URLs. Specific cases are discussed in subsequent sections.

The first part is the service specifier, (here HTTP service) which specifies the access method. Specifically this is the part before the colon. Some examples of services are: http:, gopher:, wais: and ftp:.

8.0.2 Address and Port number

The second part is usually the internet address of the server, indicated by the double forward slash (//). This address can also contain the (optional) port number the service listens at. The full name is then specified by a string like //www.address.edu:1234/, where :1234 means Port number 1234. If you want to use the default port number you can leave out both the colon and the number, i.e. //www.address.edu/.

8.0.3 Resource Location

The forward slash after the host and port specifications indicates the end of the address and the beginning of the specification for the file/resource to be accessed. This field varies depending on the service being accessed. A few simple examples follow: more detailed ones are given in the documents listed below.

8.0.4 Special Cases

In some cases the internet address and resource location are omitted. The common examples of this are news: (for accessing Usenet news group information) and mailto: (for sending e-mail).

8.0.5 Query Strings

The URL scheme also allows you to include a query string that is to be passed to the designated URL. This is indicated by placing a question mark at the end of the URL, followed by the desired query string. For example:
http://www.where.edu/cgi-bin/program?query_string_data

The query string must be specially encoded, using what is known as URL encoding. This is discussed in the CGI documentation found at NCSA and elsewhere in this document collection.

8.0.6 Some Simple URL Examples

http://info.cern.ch/hypertext/WWW/Addressing/URL/Overview.html
Retrieve the named HTML document from the CERN http server running on the default port.
gopher://gumby.brain.headache.edu:151/7fonebook.txt
Access the searchable index 'fonebook.txt' from the named gopher server, running on port number 151.
news:alt.rec.motorcycle
Access the newsgroup alt.rec.motorcycle.

For detailed information on the different URL formats see:


ToC ~ Up ~ Prev ~ Next ~ Index Introduction to HTML
© 1994-1998 by Ian Graham
Last Update: 5 January 1998