RewriteEngine On
DirectoryIndex index.php
Options -Indexes

# Browser Caching – static assets
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css                  "access plus 1 year"
    ExpiresByType application/javascript    "access plus 1 year"
    ExpiresByType text/javascript           "access plus 1 year"
    ExpiresByType image/avif                "access plus 1 year"
    ExpiresByType image/webp                "access plus 1 year"
    ExpiresByType image/jpeg                "access plus 1 year"
    ExpiresByType image/png                 "access plus 1 year"
    ExpiresByType image/gif                 "access plus 1 year"
    ExpiresByType image/svg+xml             "access plus 1 year"
    ExpiresByType image/x-icon              "access plus 1 year"
    ExpiresByType font/woff2                "access plus 1 year"
    ExpiresByType font/woff                 "access plus 1 year"
    ExpiresByType application/font-woff2    "access plus 1 year"
</IfModule>

<IfModule mod_headers.c>
    <FilesMatch "\.(css|js)$">
        Header set Cache-Control "public, max-age=31536000, immutable"
    </FilesMatch>
    <FilesMatch "\.(jpg|jpeg|png|gif|webp|avif|svg|ico|woff|woff2)$">
        Header set Cache-Control "public, max-age=31536000"
    </FilesMatch>
</IfModule>

# Honeypot
RewriteRule ^admin(/.*)?$ /api/index.php?_honeypot=1 [L,QSA]

# Backstage ohne trailing slash
RewriteRule ^backstage$ /backstage/ [R=301,L]

# Impressum
RewriteRule ^impressum/?$ impressum.php [L]

# Datenschutz
RewriteRule ^datenschutz/?$ datenschutz.php [L]

# Sprach-Routing
RewriteRule ^([a-z]{2})/?$ index.php?lang=$1 [L,QSA]

# API
RewriteRule ^api/(.*)$ api/index.php [L,QSA]