# Touch Therapies Antigua — SPA routing + caching (Apache / cPanel)
# This file ships with the built frontend (dist/) — upload it with the site.
# Deploy layout: frontend build at public_html/, backend folder at
# public_html/backend, uploads at public_html/uploads (see docs/INSTALL.md).

Options -Indexes
RewriteEngine On
RewriteBase /

# REST API → backend front controller (CMS lives at /backend/admin)
RewriteRule ^api/(.*)$ backend/public/index.php [L]

# Never rewrite uploads or the backend folder (it has its own .htaccess)
RewriteRule ^(uploads|backend)(/|$) - [L]

# Serve real files directly
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Everything else → the React app
RewriteRule ^ index.html [L]

# Browser caching
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/webp "access plus 1 month"
  ExpiresByType image/jpeg "access plus 1 month"
  ExpiresByType image/png "access plus 1 month"
  ExpiresByType image/svg+xml "access plus 1 month"
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"
</IfModule>

<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/css application/javascript application/json image/svg+xml
</IfModule>
