Options -Indexes

<FilesMatch "^\.env(?:\..*)?$">
    Require all denied
</FilesMatch>

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{THE_REQUEST} \s/+[^\s?]*/(?:app|lib|src|pages|tmp|var)(?:[/?\s]) [NC]
    RewriteRule ^ - [F,L]
    RewriteRule ^font/(.+\.(?:otf|ttf|woff2?))$ asset/fonts/$1 [L,NC]
    RewriteRule ^((?:login|register|forgot-password|reset-password)\.html)$ pages/public/$1 [L]
    RewriteRule ^([A-Za-z0-9_-]+)\.html$ protected_page.php?page=$1.html [L,QSA]
</IfModule>

<IfModule mod_headers.c>
    Header always unset X-XSS-Protection
    Header always set X-Frame-Options "DENY"
    Header always set X-Content-Type-Options "nosniff"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
    Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()"
    Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
    Header always set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'none'; base-uri 'self'; form-action 'self';"
</IfModule>

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

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 7 days"
    ExpiresByType text/javascript "access plus 7 days"
    ExpiresByType application/javascript "access plus 7 days"
    ExpiresByType image/png "access plus 30 days"
    ExpiresByType image/jpeg "access plus 30 days"
    ExpiresByType image/webp "access plus 30 days"
    ExpiresByType image/svg+xml "access plus 30 days"
    ExpiresByType font/otf "access plus 30 days"
    ExpiresByType font/ttf "access plus 30 days"
    ExpiresByType font/woff "access plus 30 days"
    ExpiresByType font/woff2 "access plus 30 days"
</IfModule>

<IfModule mod_headers.c>
    <FilesMatch "\.(css|js)$">
        Header set Cache-Control "public, max-age=604800"
    </FilesMatch>
    <Files "app-bootstrap.js">
        Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
        Header set Pragma "no-cache"
        Header set Expires "0"
    </Files>
    <FilesMatch "\.(png|jpe?g|webp|svg|otf|ttf|woff2?)$">
        Header set Cache-Control "public, max-age=2592000"
    </FilesMatch>
</IfModule>
