# =====================================================================
# Digisyn Taekwondo — Root .htaccess
# Place this file directly in public_html/ (or wherever site root is).
# =====================================================================

Options -Indexes
ServerSignature Off

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Force HTTPS (uncomment after SSL is active)
    # RewriteCond %{HTTPS} !=on
    # RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

    # Strip trailing slash for clean URLs (optional)
    # RewriteCond %{REQUEST_FILENAME} !-d
    # RewriteRule ^(.+)/$ /$1 [R=301,L]
</IfModule>

# Block access to sensitive files
<FilesMatch "\.(env|sql|md|log|ini|sh|bak|old|swp)$">
    Require all denied
</FilesMatch>
<FilesMatch "^\.htaccess$">
    Require all denied
</FilesMatch>

# 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"
    Header set Permissions-Policy "geolocation=(), microphone=(), camera=(self)"
    # Header set Strict-Transport-Security "max-age=31536000; includeSubDomains" env=HTTPS
</IfModule>

# Cache static assets
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/png  "access plus 1 month"
    ExpiresByType image/svg+xml "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>

# Compression
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/json
</IfModule>

# Custom error pages (optional — create these PHP files later)
# ErrorDocument 404 /404.php
# ErrorDocument 500 /500.php
