# Hide subversion repository files RedirectMatch 404 /\.svn.*$ # Hide vim backup scripts RedirectMatch 404 ~$ AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType text/html .html AddType text/plain .txt AddType application/x-xpinstall .xpi AddDefaultCharset utf-8 RewriteEngine On RewriteBase / # Redirect http://mb.eschew.org/figures/figure16.3.jpg # to http://mb.eschew.org/content/figures/figure16.3.jpg RewriteRule ^figures/(.+)$ content/figures/$1 [L] # Rules for testing redirects RewriteRule ^redirect/test$ test.php [last] # Hide the fact that our css file is dynamically generated RewriteRule ^chapters.css$ chapters.css.php [L] # Remove "index.php" from URLs, and make the homepage a bit saner RewriteRule ^index(.php)?$ http://mb.eschew.org/ [R=301] RewriteRule ^$ template.php?chapter=homepage [L] # This gives a 301 (permanently moved) redirect to clients # requesting e.g. http://mb.eschew.org/4.php # and redirects them to # http://mb.eschew.org/4 RewriteRule ^([1234567890]{1,2}|luggage|intro|errata|contents)\.php$ /$1 [R=301] RewriteRule ^([1234567890]{1,2}|luggage|intro|errata|contents)\.xhtml$ /$1 [R=301] # And for http://mb.eschew.org/ch1 RewriteRule ^ch([1234567890]{1,2})$ /$1 [R=301] # This takes a request for /4#section and passes it on to the template script # (responsible for making sure mb.eschew.org/4 works correctly) # This handles non-numeric "chapters" like intro and luggage, # but avoids rewriting requests for (e.g.) luggage.css RewriteCond %{REQUEST_URI} !template RewriteRule ^([1234567890]{1,2}|errata|luggage|intro|contents)([?#](.*)?)?$ template.php?chapter=$1&$3 RewriteCond %{REQUEST_URI} !stats RewriteCond %{REQUEST_URI} \.xhtml$ RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml RewriteCond %{HTTP_ACCEPT} !application/xhtml\+xml\s*;\s*q=0 RewriteCond %{THE_REQUEST} HTTP/1\.1 RewriteRule .* - [T=application/xhtml+xml]