Options -Indexes
ServerSignature Off
RewriteEngine On

# Block application internals, source data, build tools and keyword inventories.
RewriteRule ^(?:data|includes|cache|tools|database|docs)(?:/|$) - [F,L,NC]
RewriteRule ^(?:keywords|ltkeywords)\.txt$ - [F,L,NC]
RewriteRule ^(?:composer\.(?:json|lock)|README\.md)$ - [F,L,NC]

# Canonical host and HTTPS should be enabled at the production proxy/web server.
RewriteRule ^sitemap\.xml$ sitemap.php [L]
RewriteRule ^image-sitemap\.xml$ image-sitemap.php [L]

<IfModule mod_headers.c>
  Header always set X-Content-Type-Options "nosniff"
  Header always set X-Frame-Options "SAMEORIGIN"
  Header always set Referrer-Policy "strict-origin-when-cross-origin"
  Header always set Permissions-Policy "camera=(), microphone=(), geolocation=()"
  Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains" env=HTTPS
</IfModule>

<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/avif "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType text/css "access plus 30 days"
  ExpiresByType application/javascript "access plus 30 days"
</IfModule>

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

<FilesMatch "\.(?:json|log|lock|sql|py)$">
  Require all denied
</FilesMatch>

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
