<VirtualHost *:80>
    ServerName localhost
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/public

    # Set proper directory permissions
    <Directory /var/www/html/public>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
        
        # Enable URL rewriting
        <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteBase /
            
            # If the requested file or directory doesn't exist, route to index.php
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^ index.php [QSA,L]
        </IfModule>
    </Directory>

    # Deny access to sensitive files
    <FilesMatch "^\.">
        Order allow,deny
        Deny from all
    </FilesMatch>
    
    # Deny access to composer files, git files, etc.
    <FilesMatch "(composer\.(json|lock)|package(-lock)?\.json|\.git)">
        Order allow,deny
        Deny from all
    </FilesMatch>

    # Set proper error logs
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>