# Timewise backend — Apache (cPanel) rules
Options -Indexes

<IfModule mod_rewrite.c>
  RewriteEngine On
  # Force HTTPS (comment out for local testing)
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} !^(localhost|127\.0\.0\.1)
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

  # Some hosts strip the Authorization header before PHP sees it
  RewriteCond %{HTTP:Authorization} .
  RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

  # /api/v1/... -> api/index.php
  RewriteRule ^api/v1(/.*)?$ api/index.php [QSA,L]
</IfModule>

# Never serve internal files
<FilesMatch "^(_boot\.php|.*\.(sql|pem|log|md))$">
  Require all denied
</FilesMatch>

<IfModule mod_headers.c>
  Header always set X-Content-Type-Options "nosniff"
  Header always set X-Frame-Options "DENY"
  Header always set Referrer-Policy "strict-origin-when-cross-origin"
  Header always set Strict-Transport-Security "max-age=31536000" env=HTTPS
</IfModule>
