DirectoryIndex index.html

# Handles rewriting old HTML filenames for the P4SAG.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # The following looks way too complicated to be necessary, but in fact it is.
  # It is not straightforward to redirect to renamed files that used to exist
  # in a subdirectory AND be agnostic to where these files live in the document
  # root.
  RewriteBase /

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond $1#%{REQUEST_URI} ([^#]*)#(.*)\1$
  RewriteRule ^(00_preface.html)$       %2index.html [QSA,R,L]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond $1#%{REQUEST_URI} ([^#]*)#(.*)\1$
  RewriteRule ^(01_ruby.html)$          %2chapter.ruby.html [QSA,R,L]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond $1#%{REQUEST_URI} ([^#]*)#(.*)\1$
  RewriteRule ^(02_perl.html)$          %2chapter.perl.html [QSA,R,L]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond $1#%{REQUEST_URI} ([^#]*)#(.*)\1$
  RewriteRule ^(03_python.html)$        %2chapter.python.html [QSA,R,L]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond $1#%{REQUEST_URI} ([^#]*)#(.*)\1$
  RewriteRule ^(04_php.html)$           %2chapter.php.html [QSA,R,L]
</IfModule>