# 1. Disable Directory Indexing (Prevents the "Index of /banking" file list)
Options -Indexes

# 2. Enable Rewrite Engine
<IfModule mod_rewrite.c>
    RewriteEngine On
    
    # IMPORTANT: Set the base path for XAMPP subfolder
    # This tells Apache we are running inside http://localhost/banking/
    RewriteBase /banking/

    # 3. Redirect all requests to the 'public' directory
    # We exclude requests that are already pointing to the public folder to prevent loops
    RewriteCond %{REQUEST_URI} !^/banking/public/
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

# 4. Protect Sensitive Files
<FilesMatch "^\.env|composer\.(json|lock)|package\.json|phpunit\.xml|Makefile|\.gitignore|docker-compose\.yml|snapshot|structure">
    Require all denied
</FilesMatch>

# 5. Block access to hidden files (like .htaccess itself, .env, .git)
<FilesMatch "^\.">
    Require all denied
</FilesMatch>

# 6. Set default charset
AddDefaultCharset UTF-8