Options -Indexes

# Send the bare application folder to the front controller.
RedirectMatch 302 ^/pps/?$ /pps/public/

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Nothing outside public/ is meant to be requested directly.
    RewriteRule ^(app|bin|config|database|docs|routes|storage|tests|vendor)(/|$) - [F,L]

    # The platform application is a second front controller beside the tenant
    # app. Only platform/public is reachable; every other platform path is
    # handed to it so source, migrations and uploaded avatars stay private.
    RewriteRule ^platform/(src|Views|database|storage|routes|bin)(/|$) - [F,L]
    RewriteRule ^platform/?$ platform/public/index.php [QSA,L]
    RewriteCond %{REQUEST_URI} !/platform/public/
    RewriteRule ^platform/(.*)$ platform/public/index.php [QSA,L]

    # Tenant path resolution (TENANCY_ENABLED). Tenant URLs live under /t/{slug};
    # their assets stay static and every other path reaches the resolver.
    RewriteRule ^t/[a-z0-9][a-z0-9-]*/assets/(.*)$ public/assets/$1 [L]
    RewriteRule ^t/[a-z0-9][a-z0-9-]*(/.*)?$ public/index.php [QSA,L]
</IfModule>

# Never serve dotfiles such as .env, .git or editor state.
<FilesMatch "^\.">
    Require all denied
</FilesMatch>

# Word documents and the plan are working files, not web content.
<FilesMatch "\.(docx|md|csv|sql|log|jsonl)$">
    Require all denied
</FilesMatch>
