RewriteEngine On

# API requests go to the PHP API router
RewriteRule ^api(?:/.*)?$ api.php [QSA,L]

# Let existing files (including Vite build assets) be served normally
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# SPA fallback for React/Vite build
RewriteRule ^ index.html [L]
