Options -Indexes
DirectoryIndex index.html

<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=()"
    Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains" "expr=%{HTTPS} == 'on'"
</IfModule>

<FilesMatch "(^\.|\.bak$|\.config$|\.dist$|\.env$|\.ini$|\.log$|\.sql$)">
    Require all denied
</FilesMatch>

RewriteEngine On

# The migration is intentionally stored with the deployment package but is not public.
RewriteRule ^database(?:/|$) - [F,L,NC]

# Redirect .html URLs to clean URLs.
RewriteCond %{THE_REQUEST} \s/+(.+?)\.html(?:[\s?]) [NC]
RewriteRule ^(.+)\.html$ /%1 [R=301,L,NE]

# Redirect index.html to the root homepage.
RewriteCond %{THE_REQUEST} \s/+index\.html(?:[\s?]) [NC]
RewriteRule ^index\.html$ / [R=301,L,NE]

# Internally load the corresponding HTML file. Existing PHP API files are untouched.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule ^(.+?)/?$ $1.html [END]