HTML and CSS Reference
I'd like my visitors to be able to type
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
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
But I asked about
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:
it will change it to:
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: