Sams Teach Yourself HTML, CSS & JavaScript Web Publishing in One Hour a Day

(singke) #1
ptg16476052

114 LESSON 6: Working with Links


is the top-level file for all a directory’s files, calling it index.html is a good idea. Putting
such a file in place will also keep users from browsing the directory where the file is
located.
You also can specify the filename directly in the URL. In this case, the file at the end of
the URL is the one that is loaded, as in the following examples:
http://www.foo.com/home/foo/index.html
http://www.foo.com/home/foo/homepage.html
Using HTTP URLs such as the following, where foo is a directory, is also usually
acceptable:
http://www.foo.com/home/foo
In this case, because foo is a directory, this URL should have a slash at the end. Most
web servers can figure out that this is a link to a directory and redirect to the appropriate
file. Including the trailing slash helps the pages load more quickly.

Anonymous FTP


FTP URLs are used to point to files located on FTP servers—usually anonymous FTP
servers; that is, the ones that allow you to log in using anonymous as the login ID and
your email address as the password. FTP URLs also follow the standard URL form, as
shown in the following examples:
ftp://ftp.foo.com/home/foo
ftp://ftp.foo.com/home/foo/homepage.html
Because you can retrieve either a file or a directory list with FTP, the restrictions on
whether you need a trailing slash at the end of the URL aren’t the same as with HTTP.
The first URL here retrieves a listing of all the files in the foo directory. The second
URL retrieves and parses the file homepage.html in the foo directory.

Navigating FTP servers using a web browser can often be much
slower than navigating them using FTP itself because the browser
doesn’t hold the connection open. Instead, it opens the connec-
tion, finds the file or directory listing, displays the listing, and
then closes down the FTP connection. If you select a link to open
a file or another directory in that listing, the browser constructs a
new FTP URL from the items you selected, reopens the FTP con-
nection by using the new URL, gets the next directory or file, and
closes it again. For this reason, FTP URLs are best for when you
know exactly which file you want to retrieve rather than for when
you want to browse an archive.

NOTE
Free download pdf