Next / Previous / Contents / Shipman's homepage

16. Decluttering the project directory

Normally, the generated .html pages are placed in the same directory as the source .xml file. For larger documents with many sections, this can lead to a directory with a lot of files in it.

Follow this procedure to relocate all the generated .html files to a web/ subdirectory.

  1. You will need to modify your Makefile. Change the line that defines the WEB_DIR variable to look like this. Be sure to include the final “/”.

    WEB_DIR         =  web/
  2. You will need to create a file named .htaccess in the same directory as your .xml source file. This file instructs Web browsers to redirect all requests for Web files in this directory to look in the web/ subdirectory instead.

    Here is a generic .htaccess file:

    RedirectMatch /%/([^/\.]*\.html) \
        /%/web/$1 [R=301]
    RedirectMatch /%/web/homepage.html \

    Wherever % appears in the above skeleton, substitute the URL of the document's directory, starting after the http://server.domain part, but including the initial “/”. The “[R=301]” informs browsers that the page has moved permanently; without this, the Back button would not work correctly.

    For example, here is the .htaccess file for this document: