Monday, January 25, 2010

Section 4.12. Behind the Scenes: How default pageswork










4.12. Behind the Scenes: How default pages

work


  1. The user types http://www.starbuzzcoffee.com/drinks/ into the browser.

  2. HTTP Request: could I please have the file "/drinks/"?

  3. The server says "that looks like a directory, is there a default file in that directory?"


    starbuzz
    index.html
    drinks
    www.starbuzzcoffee.com



  4. Server locates a default file called "index.html" in the drinks directory.

  5. HTTP response: you asked for a directory, but I found "index.html" in that directory, so that's what I'm sending back.



4.12.1. there are no Dumb Questions



Q:

So anyone who comes to my site with the URL http://www.mysite.com is going to see my "index.html" page?

A:

Right. Or, possibly "default.htm" depending on which kind of Web server your hosting company is using. (Note that "default.htm" usually has no "l" on the end. This is a Microsoft Web Server oddity.)


There are other possible default filenames, like "index.php", that come into play if you start writing scripts to generate your pages. That's way beyond this book, but that doesn't mean you won't be doing it in the future.

Q:

So when I'm giving someone my URL, is it better to include the "index.html" part or not?

A:

Not. It's always better to leave it off. What if, in the future, you change to another Web server and it uses another default file name like "default.htm"? Or you start writing scripts and use the name "index.php"? Then the URL you originally gave out would no longer be valid.



Earl needs a little help with his URLs


Earl may know Earl, but he doesn't know U-R-L. He needs a little help figuring out the URL for each of the files below, labeled A, B, C, D, and E. On the right, write in the URL needed to retrieve each corresponding file from www.earlsautos.com.



earls_autosEarl's root folder.
index.html
directions.html
cars
new
index.html
inventory.html
used
index.html
inventory.html
images
minicooper.gif
element.gif
images
thunderbird.gif
mustang.gif






Write the URL here.


Fantastic! We're up and running on the Web. I'm already hearing great buzz about our site in the stores.


By the way, we've got a
new caffeine awareness program; we figure if we're going to be pumping people full of caffeine we want them to know how to take it to the limit. Can we point people to the caffeine information over on buzz.headfirstlabs.com from our site?













No comments: