# Protocol Droid — Apache rewrite rules
# Route /api/* to the PHP API and serve the frontend for everything else

RewriteEngine On

# Route API requests to api/index.php
RewriteRule ^api/?$ api/index.php [L]
RewriteRule ^api/(.*)$ api/index.php [L]

# Serve frontend for the root and non-api paths
# (Apache will serve index.html, style.css, app.js directly if they exist)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^$ frontend/index.html [L]

# Fallback: serve frontend/index.html for SPA routes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ frontend/index.html [L]