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

    RewriteEngine On
    RewriteBase /my-project/

    # 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]

    # Block access to sensitive files
    RewriteRule ^(\.env|composer\.(json|lock)|package(-lock)?\.json|phpunit\.xml|README\.md) - [F,L,NC]
    RewriteRule (^\.|/\.) - [F,L]

    # Rewrite requests for static assets to the public directory
    RewriteCond %{REQUEST_URI} \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|pdf|webp|txt|json|map)$ [NC,OR]
    RewriteCond %{REQUEST_URI} ^/my-project/(build|assets|images|css|js|storage)/
    RewriteRule ^(.*)$ public/$1 [L]

    # Everything else goes to the root index.php
    RewriteRule ^ index.php [L]
</IfModule>
