SetEnv NARA_MAIL_STAFF "bpage@windborne.net"
SetEnv NARA_MAIL_FROM "orders@getfoodtoday.com"
SetEnv NARA_MAIL_FROM_NAME "Nara Sushi Online Orders"
AddType application/x-httpd-php8 .php
Action application/x-httpd-php8 /cgi-sys/php-cgiwrap/windborn/php82.cgi
DirectoryIndex public/index.php

RewriteEngine On
#RewriteBase /

# --- MAINTENANCE MODE: remove this block when ready to go fully live ---

# 1) Whenever the secret preview link is used, set a bypass cookie (lasts 1440 min = 24h)
RewriteCond %{QUERY_STRING} preview=changeme123
RewriteRule ^ - [CO=bypass:1:%{HTTP_HOST}:1440:/]

# 2) Send everyone else to the placeholder. Real site is shown instead if:
#    - the request is for the placeholder itself, OR
#    - visitor's IP is your allowed IP, OR
#    - the bypass cookie is present (set by rule 1 on an earlier visit), OR
#    - this exact request carries the preview token (covers the very first visit,
#      before the cookie set in rule 1 has round-tripped back from the browser)
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteCond %{REMOTE_ADDR} !^72\.84\.65\.134$
RewriteCond %{REMOTE_ADDR} !^108\.39\.104\.162$
RewriteCond %{HTTP_COOKIE} !bypass=1
RewriteCond %{QUERY_STRING} !preview=changeme123
RewriteRule ^(.*)$ /maintenance.html [R=307,L]

# --- END MAINTENANCE MODE ---

RewriteRule ^public/ - [END]
RewriteRule ^admin$ /nara/admin/ [R=301,L]
RewriteRule ^admin/$ public/admin/index.php [END]
RewriteRule ^admin/(.*)$ public/admin/$1 [END]
RewriteRule ^assets/(.*)$ public/assets/$1 [END]
RewriteRule ^api/(.*)$ public/api/$1 [END]
RewriteRule ^closed\.php$ public/closed.php [END]
RewriteRule ^$ public/index.php [END]
RewriteRule ^index\.php$ public/index.php [END]
