HTML and CSS Reference
In-Depth Information
I'd like my visitors to be able to type
“http://www.starbuzzcoffee.com” and
not have to type the “index.html”. Is
there a way to do that?
Yes, there is. One thing we haven't talked about is what
happens if a browser asks for a directory rather than a file
from a web server. For instance, a browser might ask for:
T he imag es direc tory in
the root directo ry
http://www.starbuzzcoffee.com/images/
or
http://www.starbuzzcoffee.com/
When a web server receives a request like this, it tries to
locate a default file in that directory. Typically a default file is
called “index.html” or “default.htm” and if the server finds
one of these files, it returns the file to the browser to display.
So, to return a file by default from your root directory (or
any other directory), just name the file “index.html” or
“default.htm”.
But I asked about
“http://www.starbuzzcoffee.com”,
which looks a little different. It
doesn't have the ending “/”.
Oops, you sure did. When a server receives a request like
yours without the trailing “/” and there is a directory with
that name, then the server will add a trailing slash for you.
So if the server gets a request for:
http://www.starbuzzcoffee.com
it will change it to:
http://www.starbuzzcoffee.com/
which will cause the server to look for a default file, and in
the end it will return the file as if you'd originally typed:
http://www.starbuzzcoffee.com/index.html
Search WWH ::




Custom Search