<IfModule mod_rewrite.c>
    RewriteEngine On
    
    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
    # Redirect all requests to the public folder
    # Skip if already in public folder
    RewriteCond %{REQUEST_URI} !^/public/
    
    # Skip if the file exists in root (for files like .env, composer.json, etc.)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # Redirect to public folder
    RewriteRule ^(.*)$ /public/$1 [L]
</IfModule>

