# Requests to /static/something are redirected one level up with a 301 # The REDIRECT_END variable avoids infinite redirect loops RewriteCond %{ENV:REDIRECT_END} !^1 RewriteRule ^static/(.*)$ $1 [R=301,L] # We serve at toplevel files that are actually found in /static/ on the server RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/static RewriteRule ^(.+)$ static/$1 [E=END:1,L] # We serve without extension files that actually end in .html on the server. # Note that %{REQUEST_FILENAME} could be misleading here and contain only # a part of %{REQUEST_URI}, see AcceptPathInfo and %{PATH_INFO}. So we rather # use %{DOCUMENT_ROOT}/$1 where $1 is the request without trailing / # Earlier settings were looping on /download/ or /download/foo RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{DOCUMENT_ROOT}/$1.html -f RewriteRule ^(.*[^/])/?$ $1.html [E=END:1,L]