File names in URLs

Most often, a linking path (or a URL) includes a file name. A file name consists of two parts:

  1. file name — it is the name of the file that you want to link to or display.
  2. file extension — this specifies the file type. A word document, for instance, has the file extension .doc or docx.

This page has the file extension .asp and the file name is file-name. Table 1 lists some of the common file extensions in use for linking documents on the Web.

Extension File type
.asp Active Server Pages file
.doc or .docx Word document
.fla Flash file
.htm, html HTML document
JPG, GIF, PNG Graphic files
JSP Java Server Pages document
PDF Portable Document File
PHP PHP file

Naming files

Because server's operating system may use different file naming conventions, it is best to:

  • avoid space characters in file names
  • avoid using colons or slashes
  • avoid using special characters, and
  • use all lowercase letters; separate each successive word, for instance, with underscore (_)

If you are creating your own files, it is recommended to follow the above listed tips for file naming. These tips will minimize cross-platform incompatibilities. Consider, for example, a file name such about/us.htm. It is a valid file name on a Macintosh system; however, it will present problems for both PC and UNIX machines as the forward slash has a different meaning to these machines. Therefore, not only to avoid cross-platform computability issues but also to avoid confusing yourself or others, it is best not use characters such as :, /, ., and so on for file names.

As you may have discovered by now, a dot separates a filename and the file extension. The file extension identifies the type of information contained in the file. For instance, the .jpg, file extension indicates it is a JPEG image. Similarly, .htm, or .html denotes HTML or XHTML source files. Do not use a dot in file names because it is reserved for in helping machines distinguish file types.

Linking files

Just as the file names are important in linking so is the file extension. For the link to work correctly (meaning display content, play video, print a page, etc.), you need to use the proper file extension for the destination file (to which you attempting to link). The destination file extension should correctly match with the content inside of the file. Do not, for example, place ASP (server side) code inside an .html file and expect it will be run on the client's browser. If your attentions are to run ASP code in response to clicking of a link, place the code in a file that uses the proper file extension (.asp).

When you make a link, the server receives the request for the destination file. When serving the file, the web server read the file extension to properly process it. If the file extension is incorrect or the file contains errors, the file will not be processed correctly. Consequently, the browser is not going to display the content as it was intended. Make sure to not omit or misuse file extension when creating links to support proper functioning of links.