# .htaccess für Root-Verzeichnis

<FilesMatch "^(RESET_CACHE|reset_cache|migrate_|setup_|fix_|bulk_.*debug|old_login).*\.php$">
    Order deny,allow
    Deny from all
</FilesMatch>

# HTTPS erzwingen
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# PHP-Einstellungen
php_flag display_errors Off
php_flag log_errors On
php_value error_log /path/to/php-error.log

# Upload-Limit (Fotos von Kompaktkameras)
php_value upload_max_filesize 20M
php_value post_max_size 24M
php_value max_file_uploads 20

# Schutz vor Verzeichnis-Listing
Options -Indexes

# Schutz sensibler Dateien
# SecurityHeaders.php hinzugefügt (enthält keine Geheimnisse, aber kein Direktaufruf nötig)
<FilesMatch "^(config\.php|db\.php|security\.php|SecurityHeaders\.php)$">
    Order allow,deny
    Deny from all
</FilesMatch>

# Schutz von Backup- und Log-Dateien
<FilesMatch "\.(sql|log|bak|backup)$">
    Order allow,deny
    Deny from all
</FilesMatch>

# Session-Cookie Sicherheit
<IfModule mod_php7.c>
    php_value session.cookie_httponly 1
    php_value session.cookie_secure 1
    php_value session.use_only_cookies 1
</IfModule>

# HINWEIS: Security Headers (CSP, X-Frame-Options, HSTS etc.) werden ausschließlich
# über SecurityHeaders.php gesetzt (aufgerufen in header.php).
# Kein mod_headers-Block hier — verhindert doppelte/widersprüchliche Headers.

# Kompression aktivieren
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
</IfModule>

# Browser-Caching
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
</IfModule>
