# ResumeParsing.ai — static export served by LiteSpeed/Apache.
#
# This file ships inside public/ so `next build` copies it into out/ and every
# deploy zip carries it. It replaces two things the Node server used to do:
#
#   1. The redirect tables that lived in next.config.ts (`redirects()` is
#      unsupported under `output: "export"`). Keep the two lists in sync with
#      the routes that actually exist.
#   2. Serving /dashboard/library/<id>: the export contains ONE placeholder
#      page for that route (dashboard/library/_/) because résumé ids live in
#      the API and cannot be enumerated at build time. Every real id is
#      rewritten onto the placeholder's files; the page then reads the id
#      from the browser URL (see src/app/dashboard/library/[id]/).

Options -Indexes
DirectoryIndex index.html
ErrorDocument 404 /404.html

RewriteEngine On

# ── Stand-in pages that don't exist yet — TEMPORARY (307): browsers cache a
#    permanent redirect indefinitely, so a 308 here would keep sending people
#    to the stand-in long after the real page exists.
RewriteRule ^changelog/?$ /docs/ [R=307,L]
RewriteRule ^sdks/?$ /docs/ [R=307,L]
RewriteRule ^postman/?$ /docs/ [R=307,L]
RewriteRule ^about/?$ / [R=307,L]
RewriteRule ^blog/?$ / [R=307,L]
RewriteRule ^careers/?$ / [R=307,L]
RewriteRule ^status/?$ / [R=307,L]
RewriteRule ^partners/?$ /contact/ [R=307,L]
RewriteRule ^privacy/?$ /contact/ [R=307,L]
RewriteRule ^terms/?$ /contact/ [R=307,L]
RewriteRule ^dpa/?$ /contact/ [R=307,L]

# ── Alternate spellings of routes that DO exist — permanent (308): these
#    canonical targets aren't going to move.
RewriteRule ^home/?$ / [R=308,L]
RewriteRule ^login/?$ /signin/ [R=308,L]
RewriteRule ^sign-in/?$ /signin/ [R=308,L]
RewriteRule ^log-in/?$ /signin/ [R=308,L]
RewriteRule ^register/?$ /signup/ [R=308,L]
RewriteRule ^sign-up/?$ /signup/ [R=308,L]
RewriteRule ^create-account/?$ /signup/ [R=308,L]
RewriteRule ^documentation/?$ /docs/ [R=308,L]
RewriteRule ^api/?$ /docs/ [R=308,L]
RewriteRule ^api-docs/?$ /docs/ [R=308,L]
RewriteRule ^api-reference/?$ /docs/ [R=308,L]
RewriteRule ^plans/?$ /pricing/ [R=308,L]
RewriteRule ^support/?$ /contact/ [R=308,L]
RewriteRule ^help/?$ /contact/ [R=308,L]
RewriteRule ^sales/?$ /contact/ [R=308,L]
RewriteRule ^app/?$ /dashboard/ [R=308,L]

# ── /dashboard/library/<id> → the exported placeholder page.
#    First the flight payloads the client router fetches on soft navigation,
#    then the page itself for hard loads. The !-f / !-d guards let the real
#    placeholder directory (and any genuine file) pass through untouched.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^dashboard/library/[^/]+/((?:__next\.[^/]+|index)\.txt)$ /dashboard/library/_/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^dashboard/library/[^/]+/?$ /dashboard/library/_/index.html [L]

# ── Build assets are content-hashed; cache them forever.
<IfModule mod_headers.c>
  <If "%{REQUEST_URI} =~ m#^/_next/static/#">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </If>
</IfModule>
