Options -Indexes -MultiViews
DirectoryIndex index.html index.php

<IfModule mod_mime.c>
 AddType text/html .html .htm
 AddType text/css .css
 AddType application/javascript .js
 AddType application/xml .xml
 AddType application/rss+xml .rss
 AddType application/json .json
</IfModule>

<FilesMatch "\.(?i:html|htm)$">
 ForceType text/html
</FilesMatch>

<IfModule mod_headers.c>
 Header always set X-Content-Type-Options "nosniff"
 Header always set Referrer-Policy "strict-origin-when-cross-origin"
 Header always set X-Frame-Options "SAMEORIGIN"
 Header always set Permissions-Policy "camera=(), microphone=(), geolocation=()"
 <FilesMatch "\.(?i:html|htm)$">
  Header always unset Content-Disposition
  Header set Content-Type "text/html; charset=UTF-8"
  Header set Cache-Control "public, max-age=600, s-maxage=3600, stale-while-revalidate=86400"
 </FilesMatch>
 <FilesMatch "\.(css|js|svg)$">
  Header set Cache-Control "public, max-age=2592000, immutable"
 </FilesMatch>
 <FilesMatch "\.php$">
  Header set Cache-Control "no-cache, no-store, must-revalidate"
 </FilesMatch>
</IfModule>

<IfModule mod_deflate.c>
 AddOutputFilterByType DEFLATE text/html text/plain text/css application/javascript application/json application/xml application/rss+xml image/svg+xml
</IfModule>
<IfModule mod_brotli.c>
 AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/css application/javascript application/json application/xml application/rss+xml image/svg+xml
</IfModule>

ErrorDocument 404 /404.html
RewriteEngine On

# Protect internal data and build/backup folders from direct HTTP access.
RewriteRule ^(?:data|lib|config|cache|_v45_payload|_v45_source|_backup_before_v45_)(?:/|$) - [F,END]

# Existing physical files and directories always win. This preserves older rich biography pages.
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [END]

# Root biography URL -> alphabetically sharded physical HTML. NO .br/.gz rewrite.
RewriteCond %{DOCUMENT_ROOT}/bio/$1/$1$2.html -f
RewriteRule ^([a-z0-9])([a-z0-9-]*)\.html$ bio/$1/$1$2.html [END]
