# ── Dusk Roleplay Forums — Apache config (.htaccess) ──────────────────────────
# Shared hosting compatible — no VirtualHost or mod_env needed.
# All configuration is done in config.php directly.

Options -Indexes
RewriteEngine On

# ── Block direct access to config.php ────────────────────────────────────────
# Covers both Apache 2.2 (Order/Deny) and Apache 2.4 (Require).
<Files "config.php">
    # Apache 2.4+
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    # Apache 2.2 fallback
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Deny from all
    </IfModule>
</Files>

# ── SPA fallback ──────────────────────────────────────────────────────────────
# All non-file, non-directory requests go to index.html,
# except api.php which is handled by PHP directly.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?!api\.php).* index.html [L]

# ── Security headers ──────────────────────────────────────────────────────────
<IfModule mod_headers.c>
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set Referrer-Policy "same-origin"
</IfModule>

# ── PHP settings (shared hosting) ────────────────────────────────────────────
<IfModule mod_php.c>
    php_value session.cookie_httponly 1
    php_value session.use_strict_mode 1
    php_flag  session.cookie_samesite Lax
</IfModule>
