File- vs Directory-Based URLs

There are several ways we can control how our html files are retrieved, and how they appear in the address bar of a web browser.

Take the example file about.html. We can place it where it can be accessed:


This assumption allows for the publication of "clean URLs," as we do not need to explicitly include the index.html at the end of the URL. This is not to say that we could not have additional pages that we explicitly address. For example we could have additional html pages at the same directory level, such as an about.html.

The URL for this case would look like baseurl.com/about.html.

However, if you wished to have a “cleaner” looking URL, you could create an additional child directory labeled /about and place an index.html within that directory.

The URL for this case would look like baseurl.com/about/. Notice how we do not add index.html; instead the URL ends with a directory slash.

For our class, we will create some of our / assignment and / project directories with a sub-directory called / pages. It will contain all of our additional .html pages, not any of which will be called index.html.

This is good for those of us learning directory structure for the first time, but because these sub-directories will not have an index.html file to request, baseurl.com/pages/ will most likely return a 404 error.

The URL for this case would look like baseurl.com/pages/about.html.