RewriteEngine On
RewriteBase /PS_Launcher/

# Forward du header Authorization vers PHP — Apache FastCGI le strippe par défaut
# sur OVH mutualisé. Sans ça, $_SERVER['HTTP_AUTHORIZATION'] est vide quand le
# client envoie "Authorization: Bearer ...".
RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%1,L=0]

# HTTPS forcé (si le mutualisé OVH ne le force pas déjà)
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# Pas de listing de répertoires
Options -Indexes

# /PS_Launcher/api      -> api/index.php
# /PS_Launcher/api/foo  -> api/index.php?route=foo
# (passage par query string : pas de PATH_INFO, marche partout)
RewriteRule ^api/?$              api/index.php                        [QSA,L]
RewriteRule ^api/([^?]+)/?$      api/index.php?route=$1               [QSA,L]
