# ---------------------------------------------------------------------
# Hammad Inventory — API front controller rewrite
# ---------------------------------------------------------------------

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Strip a sub-directory install prefix if deployed under /~user/panel
    RewriteCond %{REQUEST_URI} ^/[^/]+/api
    RewriteRule ^/[^/]+/api/(.*)$ api/$1 [L]

    # Pass the Authorization header through (some CGI setups strip it)
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [QSA,L]
</IfModule>

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

ErrorDocument 404 /index.php