4.1 Changing the Primary Document Directory

You probably don't want to make all the files on your file system available to remote clients. An easy way to restrict access is to keep all of your server's documents in a central location, known as the document root or primary document directory.

Another benefit of the document directory is that you can move your documents to a new directory (perhaps on a different disk, for example, if you are moving your Web site to a new server) without changing any of your URLs, because the paths specified in the URLs are relative to the primary document directory.

For example, if your document directory is sys:/apache2/htdocs, a request such as http://www.digitalairlines.com/products/info.html tells the server to look for the file info.html in sys:/apache2/htdocs/products/info.html.

If you change the location where documents are stored (by moving all the files and subdirectories), you only have to specify the new primary document directory that the server is using, instead of mapping all URLs to the new directory or telling users to look in the new directory.

By default, the primary document directory is set to the volume:/apache2/htdocs/ directory using the DocumentRoot directive. The primary document directory is the directory from which Apache serves files.

It is unlikely that you will need to change the default primary document directory. However, if you do, keep in mind that the deeper into a file structure Apache needs to go, the longer it takes Apache to examine the directories. To optimize performance, keep the primary document directory as close to the root of your server's volume as possible.

To work with server content in Apache Manager, use the Content Management tab.

Primary Document Directories page

To change the location of the primary document directory:

  1. On the Primary Document Directory page, specify the path, including the directory name that Apache should serve files from.

    Type a full path, such as sys:/apache2/htdocs.

    IMPORTANT:Do not include a trailing slash, as in sys:/apache2/htdocs/.

  2. Click Save > Save to save your changes.

    or

    Click Save > Save and Apply to save your changes and restart Apache so your changes are immediately put into effect.

    For information about where configuration information is stored, see Section 2.3.3, Saving Configuration Changes and Restarting Apache in Apache Manager.

For more information related to mapping directories to URLs, see Mapping URLs to Filesystem Locations on the Apache Web site.