Options -Indexes -MultiViews
DirectoryIndex index.php
RewriteEngine On
# IONOS maps this subdomain to a webspace subdirectory. Resolve relative
# rewrites against the public domain root instead of that physical path.
RewriteBase /

# Never expose private configuration, database files, source or dotfiles.
RewriteRule ^(?:app|config|storage)(?:/|$) - [F,L,NC]
RewriteRule (^|/)\. - [F,L]
<FilesMatch "\.(?:sqlite|sqlite3|db|log|properties|bak|md)$">
    Require all denied
</FilesMatch>

# Canonical public URLs never have .php at the end.
RewriteCond %{THE_REQUEST} \s/+index\.php(?:[?\s]) [NC]
RewriteRule ^index\.php$ / [R=301,L]
RewriteRule ^(highscores|shop|items|monsters|quests|minigames|play)\.php$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

<IfModule mod_headers.c>
    Header always set X-Content-Type-Options "nosniff"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set Permissions-Policy "camera=(), microphone=(), geolocation=()"
    Header always set Content-Security-Policy "default-src 'self'; img-src 'self' data:; style-src 'self'; script-src 'self'; font-src 'self'; connect-src 'self'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'"
</IfModule>
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/webp "access plus 7 days"
    ExpiresByType image/png "access plus 7 days"
    ExpiresByType image/gif "access plus 7 days"
    ExpiresByType font/woff2 "access plus 1 month"
</IfModule>
