# ==========================================================================
# NADIPLAY frontend  ·  public_html/4kmovies.vip/nadiplayer/.htaccess
# ==========================================================================
# This file does TWO things:
#   1. Lets React Router handle client-side URLs like /nadiplayer/pair,
#      /nadiplayer/login, etc. — Apache falls back to index.html.
#   2. Leaves /nadiplayer/api/* alone so cPanel's Passenger config can
#      forward it to the Python app.  cPanel automatically injects its
#      own rules when you set the Python app URL to /nadiplayer/api,
#      so we must NOT rewrite anything under /api/.
# ==========================================================================

# Ensure mod_rewrite is on
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /nadiplayer/

  # Do NOT rewrite anything under /nadiplayer/api/ — those go to Python.
  RewriteRule ^api(/|$) - [L]

  # Real files and folders are served directly.
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^ - [L]

  # Everything else → single-page app.
  RewriteRule ^ index.html [L]
</IfModule>

# Long cache for fingerprinted assets (they have content hash in filename).
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType application/javascript "access plus 1 year"
  ExpiresByType text/css               "access plus 1 year"
  ExpiresByType image/png              "access plus 1 month"
  ExpiresByType image/jpeg             "access plus 1 month"
  ExpiresByType image/webp             "access plus 1 month"
  ExpiresByType font/woff2             "access plus 1 year"
</IfModule>

# index.html should always be revalidated.
<Files "index.html">
  Header set Cache-Control "no-cache, no-store, must-revalidate"
</Files>

# Gzip — most shared hosts enable DEFLATE by default.
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/css application/javascript application/json
</IfModule>
