# Long Cheng Plaza — TEMPORARY (static preview) Apache / cPanel config.
#
# This is NOT the production .htaccess. It differs in three ways:
#   1. No seo.php / sitemap.php / robots.php — this bundle ships no PHP, so the
#      SPA fallback goes straight to index.html. Link previews therefore show
#      the site-wide defaults from index.html on every URL, not per-shop tags.
#   2. /api/* is answered with a hard 404 so the front end's "API is missing →
#      use the bundled src/data copy" path trips immediately instead of parsing
#      an index.html body (see src/lib/publicApi.ts).
#   3. Indexing is blocked (robots.txt + X-Robots-Tag) — a staging copy of the
#      site must never compete with longchengplaza.co.zw in search results.
#
# The production file lives at public/.htaccess in the repo.

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  # Force HTTPS
  RewriteCond %{HTTPS} !=on
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

  # No backend in this bundle: fail API calls fast rather than handing the
  # fetch client an HTML document it has to sniff and reject.
  RewriteRule ^api(/|$) - [R=404,L]

  # SPA fallback — every non-file, non-directory request renders the app.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

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

<IfModule mod_expires.c>
  ExpiresActive On

  # Hashed build assets are immutable
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType font/woff2 "access plus 1 year"

  # The entry document must always be revalidated
  ExpiresByType text/html "access plus 0 seconds"
</IfModule>

<IfModule mod_headers.c>
  <FilesMatch "\.(css|js|mjs|jpg|jpeg|png|webp|svg|woff2)$">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </FilesMatch>
  <FilesMatch "\.html$">
    Header set Cache-Control "no-cache, must-revalidate"
  </FilesMatch>

  # Keep the staging copy out of every index, including image and link search.
  Header set X-Robots-Tag "noindex, nofollow, noarchive, noimageindex"

  Header set X-Content-Type-Options "nosniff"
  Header set X-Frame-Options "SAMEORIGIN"
  Header set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

ErrorDocument 404 /index.html
