# ----------------------------------------------------------------------
# BIZTONSÁGI BEÁLLÍTÁSOK & ALAPOK
# ----------------------------------------------------------------------

# Mappa listázás tiltása (SEO és biztonság)
Options -Indexes

# Szerver információk elrejtése
ServerSignature Off

<IfModule mod_headers.c>
    # Alapvető biztonsági fejlécek (Hiányoztak)
    Header set X-Content-Type-Options "nosniff"
    Header set X-Frame-Options "SAMEORIGIN"
    Header set Permissions-Policy "geolocation=(), microphone=(), camera=()"
    Header set Cross-Origin-Opener-Policy "same-origin"
    Header set Accept-CH "DPR, Width, Viewport-Width"
    
    # HSTS (Csak akkor aktiváld, ha a HTTPS már hibátlanul működik!)
    Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"

    # JAVÍTOTT CSP (A hibás statikus nonce eltávolítva)
    Header set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' https:; connect-src 'self'; media-src 'self' https:; object-src 'none'; base-uri 'none'; frame-ancestors 'none'; form-action 'self'; manifest-src 'self'; worker-src 'self' blob:;"
</IfModule>

# ----------------------------------------------------------------------
# SEO & ÁTIRÁNYÍTÁSOK (HTTPS és Non-WWW kényszerítés)
# ----------------------------------------------------------------------
<IfModule mod_rewrite.c>
    RewriteEngine On
    
    # 1. Átirányítás WWW-ről NON-WWW-re (SEO miatti duplikáció elkerülése)
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

    # 2. Átirányítás HTTPS-re
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

# ----------------------------------------------------------------------
# FONT CORS VÉDELEM
# ----------------------------------------------------------------------
<IfModule mod_headers.c>
    <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2)$">
        Header set Access-Control-Allow-Origin "https://regen.hu"
    </FilesMatch>
</IfModule>

# ----------------------------------------------------------------------
# GYORSÍTÓTÁRAZÁS (CACHE-CONTROL & EXPIRES)
# ----------------------------------------------------------------------
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/html "access plus 0 seconds"
    ExpiresByType text/css "access plus 1 year"
    ExpiresByType application/javascript "access plus 1 year"
    ExpiresByType text/javascript "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/webp "access plus 1 year"
    ExpiresByType image/svg+xml "access plus 1 year"
    ExpiresByType image/x-icon "access plus 1 week"
    ExpiresByType font/woff "access plus 1 year"
    ExpiresByType font/woff2 "access plus 1 year"
</IfModule>

<IfModule mod_headers.c>
    <FilesMatch "\.(ico|pdf|flv|swf|js|mjs|css|gif|png|jpe?g|jpg|webp|svg|woff2|woff)$">
        Header set Cache-Control "max-age=31536000, public"
    </FilesMatch>
</IfModule>

# ----------------------------------------------------------------------
# TÖMÖRÍTÉS (BROTLI & GZIP)
# ----------------------------------------------------------------------
# Modern Brotli tömörítés (ha a szerver támogatja)
<IfModule mod_brotli.c>
    AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/javascript application/json application/xml image/svg+xml font/woff font/woff2
</IfModule>

# GZIP tömörítés (tartalék, ha a Brotli nem elérhető)
<IfModule mod_deflate.c>
    <IfModule !mod_brotli.c>
        AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css text/javascript application/javascript application/json application/xml image/svg+xml font/woff font/woff2
    </IfModule>
</IfModule>

<IfModule mod_headers.c>
    # Proxy gyorsítótárazás segítése
    Header append Vary Use-Agent
</IfModule>

