# Liara's generic PHP platform serves the project root as DocumentRoot and offers
# no way to point it at public/ (only the dedicated "laravel" platform does that
# automatically, but that would run artisan/npm — wrong for Symfony). Symfony's
# recommended setup is DocumentRoot=public/; since that's unavailable here, forward
# every request into public/ and let public/.htaccess route to index.php.
DirectoryIndex public/index.php

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Block direct external access to the public/ prefix (e.g. /public/index.php).
    # Real assets are referenced as /build/... not /public/... . THE_REQUEST holds
    # the ORIGINAL request line, so this does NOT match the internal rewrite below.
    RewriteCond %{THE_REQUEST} \s/+public/ [NC]
    RewriteRule ^ - [R=404,L]

    # Forward everything into public/. The negative lookahead (?!public/) stops the
    # internal rewrite from looping (public/ -> public/public/...). Anything outside
    # public/ (e.g. /.env, /src/...) maps to a non-existent public/<path> and falls
    # through to the front controller as a 404 — root files are never served.
    RewriteRule ^(?!public/)(.*)$ public/$1 [L]
</IfModule>
