# ============================================================
# CaseHouse — Apache configuration for shared/cPanel hosting
# ============================================================

# Prevent directory browsing
Options -Indexes

# Protect sensitive files from direct access
<FilesMatch "\.(sql|md|log|env)$">
  Require all denied
</FilesMatch>

# Block direct access to /config folder from the web
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteRule ^config/ - [F,L]
</IfModule>

# ---- Browser caching for speed ----
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/jpg "access plus 1 month"
  ExpiresByType image/jpeg "access plus 1 month"
  ExpiresByType image/png "access plus 1 month"
  ExpiresByType image/webp "access plus 1 month"
  ExpiresByType text/css "access plus 1 week"
  ExpiresByType application/javascript "access plus 1 week"
</IfModule>

# ---- Gzip compression for speed ----
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/css application/javascript text/javascript application/json
</IfModule>

# ---- Basic security headers ----
<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"
</IfModule>

# Force HTTPS (uncomment once your SSL certificate is active)
# RewriteEngine On
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
