How do web servers work?

What happens when you enter in the address field of your browser the URL http://www.aprelium.com/doc/sample.html?

First, the browser slices the URL in 3 parts:



Then, the browser establishes a connection channel with the web server on the computer which host name is www.aprelium.com and requests the document which virtual path is doc/sample.html. The server decodes the request and maps the virtual path to a real one, which should match an existing file. The server sends the file to the browser with some useful information such as its last modification time and its MIME type. The MIME type helps the browser deciding how to display the received document. In our example, it is a HTML file. So the server sets its MIME type to text/html and the browser understands that it must render it as text.

Sometimes you enter a URL without an explicit filename such as http://www.aprelium.com/doc. The browser sends the request to the web server as in the previous example. The server detects that the virtual path maps to a directory and not to a file. It searches then in this directory an index file. Index files are usually named index.html or index.htm. If it finds for example index.html, it acts as if the requested URL was http://www.aprelium.com/doc/index.html. If no index file is found, the web server generates a listing of the directory contents and sends it to the browser or reports an error.

Copyright © 2001-2003 by Aprelium Technologies