<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /fcorex/
  
  # API and Backend Requests - Let them pass through
  RewriteRule ^(backend|setup\.php) - [L]

  # Existing files and directories
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^ - [L]

  # SPA Routing - Rewrite everything else to index.html
  RewriteRule . index.html [L]
</IfModule>
