Default documents, directory browsing, and error messages
Objective
Describe the concepts of default documents, directory browsing, and error messages.
Default Documents, Directory Browsing
When a server receives a request for a URL that refers to a directory rather than to a specified document, the server may operate in one of the following ways, depending on how it is configured:
It may return a default document present in that directory.
It may generate an error and refuse the request.
It may return a directory listing.
Question: What is the "Default Document" within the context of Apache Web Server?
In the context of the Apache web server, the "default document" refers to the file that is displayed to a website visitor when they access the root directory of a website. When a visitor enters a URL for a website without specifying a specific file or page, the web server will look for a default document in the root directory and display it to the visitor.
The default document is specified in the Apache configuration file, typically named httpd.conf or apache2.conf, and can be set to any file name or file type. The most common default document file names are index.html, index.php, and default.html, but this can be customized to fit the needs of the website.
It is important to set a default document to ensure that visitors to the website are greeted with a welcome page or relevant content instead of an error message or a directory listing. Without a default document, visitors may be confused about the purpose of the website or have difficulty finding the content they are looking for.
To set a default document in Apache, the DirectoryIndex directive can be used in the configuration file. For example, to set the default document to index.html, the following code can be added to the configuration file:
DirectoryIndex index.html
The default document in the context of the Apache web server is the file that is displayed to visitors when they access the root directory of a website. Setting a default document is an important step in ensuring that visitors are presented with relevant content and can easily navigate the website. The default document is specified in the Apache configuration file using the DirectoryIndex directive.
Default Document
The first option listed is the most common. You can configure any Web server, whether it is IIS, Nginx Webserver, or Apache Server, to refer to a default document automatically if the user does not specify a document. For example, a request for the URL
https://www.dispersednet.com
usually returns the default document, or home page, from the server resource root directory on the machine
https://www.dispersednet.com
You can name your default document anything you wish, as long as you configure the server to recognize this name.
Common default document names include index.htm, index.html, default.htm, and welcome.html. IIS defaults to default.htm, and Apache Server defaults to index.html. You can change this name at any time by customizing the configuration files.
Common HTTP error messages
Below is a partial list of common HTTP error messages:
Directory listing
All Web servers have a directory listing feature. This involves setting the server's permissions so that the server automatically formats the directory's contents in HTML, then reports the contents to the browser. This HTML page represents each file as an HTML link in alphabetical order. By clicking on the corresponding link, the browser user may read and/or download the listed file. It is generally not a good idea to allow this option, because it may reveal too much information about the workings of your server. You will learn more about security issues in a later module.
In the next lesson, Web site development software will be discussed.
Web Servers - Quiz
Click the Quiz link to take a multiple-choice quiz about Web servers. Web Servers - Quiz