Understanding URLs

The URL is an acronym that stands for Uniform Resource Location. It represents an address of a document available on the World Wide Web (WWW). Although a URL of your favorite website may look long and complex, it simply consists of four basic parts:

  1. protocol
  2. hostname
  3. folder name (also referred to as directory), and
  4. file name

Each of these four parts have a specific purpose. Read below for more. See figure 1 that shows the anatomy of a URL.

Figure 1 showing four basic parts of a URL: protocol, hostname, folder name, and file name
Figure 1 showing four basic parts of a URL: protocol, hostname, folder name, and file name


You probably have heard of the protocols such as http, ftp, telnet, and so on. But you may have wondered what all these protocols are about? A protocol can be defined as a computer language that allows computers to transfer information. More specifically, a protocol tells the browser how to negotiate resource-specific services. For example, the web browser uses the http (Hypertext Transfer Protocol) to contact the web server and retrieve the appropriate content. Similarly, a FTP client uses the FTP (File Transfer Protocol) to send and receive files to and from a server.

The most commonly used protocol is http. As you may have realized, it is used in links to indicate where a specific document is located on WWW. It is also used to retrieve document from the WWW. Given the exponential growth of web documents and web sites in a short period of time, http has become one of the popular protocols in use today.

Although less frequently used than http, ftp and other protocols are also often invoked by hyperlinks. See table 1 for some of the common protocols that can be used in links.

Table 1 commonly used protocols
Protocol Protocol indicator Description
ftp ftp:// allows downloading of files from a remote FTP server
file file:// Allows accessing of files from local hard drive
gopher gopher:// Allows access to documents located on a gopher server
http http:// allows access to documents located on the web
mailto mailto: although it is not a standard, most browsers supports it to open user's email client
news news: this protocol is used to connect to USENET newsgroup
telnet telnet:// This protocol allows a telnet session to a telnet host

As the table indicates above, if you wanted to make link to a local document, you would use the file:// protocol indicator. The use of the file:// protocol indicator will instruct the web browser that the file is on the local machine. Similarly, if you want to link to a file on a FTP server, you would use the ftp:// protocol to instruct the ftp client to access a FTP server.


A hostname is the name of a server that holds web related documents. Each web server has a specific address (specifically, IP address). Examples of hostname include www.google.com, www.yahoo.com, and www.scriptingmaster.com. Each of these has a specific IP address,, and, respectively. It is not surprising that IP addresses are more difficult to remember than hostnames. Do you access Google.com or your favorite website by its IP address? Chances are you access websites by their hostname rather than an IP address. When creating a link, a host name is used rather than IP address. When a hostname used to access a website, it is automatically routed to the corresponding IP address.

Folder name

A folder name is the chunk of information that follows a hostname. A URL may contain zero, one, or more folder names. A URL directory is a folder name in the URL. In the URL www.google.com/aboutus/goog.htm, aboutus is the folder or URL directory name.

This page provides more information on folder names to help you with constructing links in XHTML.

File name

For the proper functioning of a URL, it requires a valid file name. Not only file name indicates what item you want to access from the server but also instructs the server how to handle a specific file. For instance, an ASP type file would require execution on the server while a .JPEG or HTML file can be sent to the client without having any processing take place on the server.

Please access this page to read more on use of file name in URLs.