# Main .htaccess for Namecheap public_html
# Copy this to public_html/.htaccess

RewriteEngine On

# Force HTTPS (optional - uncomment if needed)
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Handle API requests - route to PHP
RewriteCond %{REQUEST_URI} ^/api/
RewriteRule ^api/(.*)$ api/index.php [QSA,L]

# Handle static assets (if file exists, serve it)
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

# Handle React client-side routing (SPA fallback)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.html [L]
