# Antalya Restaurant - Apache Configuration
# FIXED - Handles Next.js static export with trailing slashes 100%

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Prevent directory listing and disable MultiViews (Critical for Next.js)
    Options -Indexes
    Options +FollowSymLinks
    Options -MultiViews

    # Force trailing slash for directory-like URLs (helps with DirectoryIndex)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
    RewriteRule (.*)$ /$1/ [R=301,L]

    # Handle Next.js App Router RSC payload files
    # (Removed RSC rewrites as we are disabling prefetch instead)


    # 1. Custom 404 handling
    ErrorDocument 404 /404.html

    # 2. Standard directory handling (Optional explicitly, usually default)
    DirectoryIndex index.html
</IfModule>

# Security Headers
<IfModule mod_headers.c>
    Header set X-Content-Type-Options "nosniff"
    Header set X-Frame-Options "DENY"
    Header set X-XSS-Protection "1; mode=block"
    Header set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

# Cache Control
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 1 month"
    ExpiresByType text/html "access plus 0 seconds"
    ExpiresByType text/xml "access plus 0 seconds"
    ExpiresByType application/xml "access plus 0 seconds"
    ExpiresByType application/json "access plus 0 seconds"
    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 image/webp "access plus 1 year"
    ExpiresByType image/svg+xml "access plus 1 year"
    ExpiresByType image/x-icon "access plus 1 year"
    ExpiresByType application/javascript "access plus 1 year"
    ExpiresByType text/css "access plus 1 year"
</IfModule>
