<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /var/www/bagisto/public

    <Directory /var/www/bagisto/public>
        Options -Indexes +FollowSymLinks
        AllowOverride None
        Require all granted

        DirectoryIndex index.php

        RewriteEngine On

        # Deny dotfiles/dotdirs (except .well-known)
        RewriteRule "(^|/)\.(?!well-known)" - [F]

        # Laravel front controller
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^ index.php [L]
    </Directory>

    # --- Long-lived cache for static assets ---
    <FilesMatch "\.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|webp|avif)$">
        Header set Cache-Control "public, max-age=31536000, immutable"
    </FilesMatch>

    # --- Security headers ---
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-XSS-Protection "1; mode=block"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"

    # --- Upload / body size ---
    LimitRequestBody 104857600

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
