# SleepEasy
Options -Indexes
DirectoryIndex index.php index.html

<IfModule mod_rewrite.c>
  RewriteEngine On
  # Force HTTPS (PayFast, WhatsApp and sign-in need it)
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP:X-Forwarded-Proto} !=https
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  # Works at the domain root or in a folder such as /sleepeasy: work out the app's own base path
  RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$
  RewriteRule ^(.*)$ - [E=SE_BASE:%1]
  # Short booking links: book/your-lodge  →  ?lodge=your-lodge
  RewriteRule ^book/([a-z0-9-]+)/?$ %{ENV:SE_BASE}?lodge=$1 [L,R=302]
  # Privacy policy (needed by Meta and Google sign-in)
  RewriteRule ^privacy/?$ privacy.html [L]
  # Lodge websites: /site/your-lodge
  RewriteRule ^site/([a-z0-9-]+)/?$ site.php?lodge=$1 [L,QSA]
</IfModule>

<IfModule mod_headers.c>
  Header always set X-Content-Type-Options "nosniff"
  Header always set Referrer-Policy "strict-origin-when-cross-origin"
  <FilesMatch "^sw\.js$">
    Header set Cache-Control "no-cache"
  </FilesMatch>
</IfModule>

<FilesMatch "\.(md|sql)$|sample\.php$">
  <IfModule mod_authz_core.c>
    Require all denied
  </IfModule>
</FilesMatch>
