Options -Indexes RewriteEngine On # Route all /api/* requests to api.php RewriteCond %{REQUEST_URI} ^/api(/|$) RewriteRule ^api(/.*)?$ api.php [QSA,L] # Everything else serves static files or index.html RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.html [L]