# SEC-012: Block direct access to .env and hidden files
<FilesMatch "^\.">
    Require all denied
</FilesMatch>

# SEC-032: Block direct access to composer.json and composer.lock
<FilesMatch "composer\.(json|lock)$">
    Require all denied
</FilesMatch>

RewriteEngine On

<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"
  ExpiresByType text/javascript "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/x-icon "access plus 1 year"
  ExpiresByType font/woff2 "access plus 1 year"
</IfModule>

<IfModule mod_headers.c>
  <FilesMatch "\.(?:css|js|svg|png|jpe?g|webp|ico|woff2)$">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </FilesMatch>
  <FilesMatch "\.(?:html|php)$">
    Header set Cache-Control "no-store"
  </FilesMatch>
</IfModule>

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

# Serve existing files/directories directly
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Route all other requests through front controller
RewriteRule ^ index.php [QSA,L]
