# Sample Apache configuration for mdssg in CGI mode.
#
# The first rule is the one that matters: an already-rendered page is served
# straight off disk and Python is never started. Only a cache miss reaches the
# handler.

Options +ExecCGI -Indexes
AddHandler cgi-script .cgi

RewriteEngine On

# Serve a cached render if there is one.
RewriteCond %{DOCUMENT_ROOT}/cache%{REQUEST_URI}index.html -f
RewriteRule ^(.*)$ /cache/$1index.html [L]

# Leave real files alone: stylesheets, images, anything in static/.
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

# Everything else is a page to render.
RewriteRule ^(.*)$ /cgi-bin/mdssg.cgi/$1 [L,QSA]

# The notes, the graph index and the build cache are not public.
RedirectMatch 404 ^/content/
RedirectMatch 404 ^/\.mdssg/
