<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Deny direct access to Blade templates and sensitive files/folders
    RewriteRule (^|/).*\.blade\.php$ - [F,L]
    RewriteRule (^|/)\.env($|/) - [F,L]
    RewriteRule (^|/)\.git - [F,L]
    RewriteRule (^|/)composer\.(json|lock)$ - [F,L]
    RewriteRule ^package(-lock)?\.json$ - [F,L]
    RewriteRule ^vite\.config\.js$ - [F,L]
    RewriteRule ^phpunit\.xml$ - [F,L]
    RewriteRule ^artisan$ - [F,L]
    RewriteRule ^tests/ - [F,L]
    RewriteRule ^node_modules/ - [F,L]
    RewriteRule ^database/ - [F,L]
    RewriteRule ^storage/(app|framework|logs)/ - [F,L]
    RewriteRule ^resources/ - [F,L]
    RewriteRule ^app/ - [F,L]
    RewriteRule ^bootstrap/ - [F,L]
    RewriteRule ^vendor/ - [F,L]
    RewriteRule ^public/ - [F,L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Serve static assets from public/ if file exists
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{DOCUMENT_ROOT}/E31231762/public/$1 -f
    RewriteRule ^(.*)$ public/$1 [L]

    # Send Requests To Front Controller (index.php in root)
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
