--- /dev/null
+# Disable CGI scripts and static-cat; serve everything as static content
+# from Apache unless otherwise specified.
+<Files *>
+ SetHandler none
+</Files>
+
+RewriteEngine On
+RewriteBase /
+
+# Serve some CGI scripts from _wiki-cgi
+RewriteRule ^ikiwiki.cgi$ _wiki-cgi/ikiwiki.cgi [L]
+RewriteRule ^update.cgi$ _wiki-cgi/update.cgi [L]
+
+# Trailing-slash directories served from _wiki
+RewriteCond %{DOCUMENT_ROOT}/_wiki%{REQUEST_URI} -d
+RewriteRule ^(.*[^/])$ $1/ [R=permanent,L]
+
+# Serve most content from _wiki
+RewriteCond %{DOCUMENT_ROOT}/_wiki%{REQUEST_URI} -d [OR]
+RewriteCond %{DOCUMENT_ROOT}/_wiki%{REQUEST_URI} -f
+RewriteRule ^(.*)$ _wiki/$1 [L]
+
+# Give a better error page for 404s
+ErrorDocument 404 /_wiki-cgi/ikiwiki.cgi