# Hard Gaming CMS – Apache (Strato)
Options -Indexes
DirectoryIndex index.php
DirectorySlash Off

<IfModule mod_rewrite.c>
    RewriteEngine On
    # Basis-Pfad automatisch erkennen: funktioniert direkt auf der Domain (Strato)
    # und in Unterordnern wie localhost/hardgaming (XAMPP). Kein RewriteBase nötig.
    RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$
    RewriteRule .* - [E=HG_BASE:%1]

    # Aufruf des Ordners ohne Schrägstrich (z. B. localhost/hardgaming) → mit Schrägstrich weiterleiten
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteCond %{REQUEST_URI} !/$
    RewriteRule ^$ %{REQUEST_URI}/ [R=301,L]

    # HTTPS erzwingen (nach Einrichtung von SSL einkommentieren)
    # RewriteCond %{HTTPS} off
    # RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # Interne Ordner und alle PHP-Dateien außer index.php sperren
    RewriteRule ^(core|storage|install|pro/views|modules/[^/]+/views)(/|$) - [F,L]
    RewriteRule ^(config\.php|build\.sh|dev-router\.php)$ - [F,L]
    RewriteRule ^modules/[^/]+/module\.json$ - [F,L]
    RewriteRule ^(?!index\.php$).+\.php$ - [F,L]

    # Alles, was keine echte Datei ist (auch Ordner wie /admin), läuft über index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ %{ENV:HG_BASE}/index.php [QSA,L]
</IfModule>

<FilesMatch "\.(sqlite|log|md|lock|sh)$">
    Require all denied
</FilesMatch>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/webp "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType application/javascript "access plus 1 week"
</IfModule>
