# BrainPig – Apache optimizations (heinv.id.vn)
Options -Indexes

<IfModule mod_rewrite.c>
  RewriteEngine On
  # If app is in document root, leave RewriteBase /
  # If in /demo, use RewriteBase /demo/
  # RewriteBase /
</IfModule>

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

# Browser cache for static files
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/css "access plus 7 days"
  ExpiresByType application/javascript "access plus 7 days"
  ExpiresByType image/svg+xml "access plus 30 days"
  ExpiresByType image/png "access plus 30 days"
  ExpiresByType image/jpeg "access plus 30 days"
  ExpiresByType image/webp "access plus 30 days"
  ExpiresByType font/woff2 "access plus 30 days"
</IfModule>

<IfModule mod_headers.c>
  Header set X-Content-Type-Options "nosniff"
  Header set X-Frame-Options "SAMEORIGIN"
  Header set Referrer-Policy "strict-origin-when-cross-origin"
  <FilesMatch "\.(css|js|svg|png|jpg|jpeg|webp|woff2)$">
    Header set Cache-Control "public, max-age=604800, immutable"
  </FilesMatch>
</IfModule>

# Block sensitive paths
<IfModule mod_authz_core.c>
  RedirectMatch 403 (?i)^.*/(config|includes|database)/.*\.php$
</IfModule>

# PHP limits (if allowed by host)
<IfModule mod_php.c>
  php_value upload_max_filesize 20M
  php_value post_max_size 25M
  php_value max_execution_time 120
</IfModule>
