# >>> mdx front controller >>> (managed by deploy/cpanel-update.sh — edit above or below this block, not inside)
# Sends every URL that is not a real file to backend/public/index.php, which is what makes /login, /admin and
# /units/{id} work. cPanel's own lines (the PHP handler) stay wherever they are in this file.
DirectoryIndex index.php

<IfModule mod_negotiation.c>
    # MultiViews would answer /login with a file it guessed instead of letting Symfony route it.
    Options -MultiViews
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Apache drops the Authorization header on CGI/FPM, which would make every API call 401: the API is Bearer only.
    RewriteCond %{HTTP:Authorization} .+
    RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]

    # /index.php/foo → /foo, so one URL is not reachable under two spellings.
    RewriteCond %{ENV:REDIRECT_STATUS} =""
    RewriteRule ^index\.php(?:/(.*)|$) /$1 [R=301,L]

    # A real file (the UI build, favicon, robots.txt) is served as it is.
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ - [L]

    RewriteRule ^ index.php [L]
</IfModule>
# <<< mdx front controller <<<
