file URI scheme

From Wikipedia, the free encyclopedia

The file: URL is a URL schema specified in RFC 1630 and RFC 1738, typically used to retrieve files from within one's own computer. A file: URL takes the form of

file://host/path

where host is the fully qualified domain name of the system on which the path is accessible, and path is a hierarchical directory path of the form directory/directory/.../name. If host is omitted, it is taken to be "localhost".

file: URLs are rarely used in Web pages on the Internet, since they make the assumption that such a file exists on the client's computer. The host specifier can be used to retrieve a file from an external source, although no specific file-retrieval protocol is specified; or to inform the user that no mechanism to access that machine is available.

On MS Windows systems, the normal colon (:) after a device letter has sometimes been replaced by a vertical bar (|) in file URLs. For example, to refer to file FOO.BAR in the top level directory of the C disk, the URL file:///C|/FOO.BAR was used. This reflected the original URL syntax, which made the colon a reserved character in a path part. For network shares, add an additional two slashes. For example, \\host\share\dir\file.txt, becomes file:////host/share/dir/file.txt.

Mozilla browsers refuse to follow file: links on a page that it has fetched with the HTTP protocol, so that the page's own URL is an http: URL. When you click on such a link, nothing happens. The purpose is presumably security: to prevent a remote page from executing a program on the visitor's computer. The file: links work on Mozilla on pages that are local files on the user's disk. Mozilla browsers can be configured to override this security restriction as detailed in Mozillazine's "Links to Local Pages Don't Work".

Mozilla browsers also treat file: URLs similarly to the Gopher protocol in the way a directory is represented textually (i.e. the source) and graphically.

Internet Explorer browsers, prior to version 7, will attempt to access file: URLs even if they reside on pages fetched over HTTP.

The original web browser, WorldWideWeb, provided editing of resources in file: space [1]. No modern browsers replicate this ability.

[edit] External links