<VirtualHost *:80>
    ServerName localhost
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/html/public/

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

        Header always set Access-Control-Allow-Origin "*"

        RewriteEngine On

        # Allow Laravel/PHP front controller index.php
        # Block direct access to other PHP-like files
        RewriteCond %{REQUEST_URI} !^/index\.php$ [NC]
        RewriteRule \.(php|php3|php4|php5|php7|php8|phtml|phar)$ - [F,L]
    </Directory>

    # Block hidden files like .env, .git, .htaccess
    <FilesMatch "^\.">
        Require all denied
    </FilesMatch>

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