# PandaDev DNS - Apache/LiteSpeed
# Keep this file in public_html/dns/. Do not remove the data/.htaccess guard.

DirectoryIndex index.php index.html

# Directory listing disabled. Do not use broad deny rules on the whole site.
Options -Indexes

<IfModule mod_rewrite.c>
  RewriteEngine On

  # Canonical hostname first.
  RewriteCond %{HTTP_HOST} !^pandadev\.site$ [NC]
  RewriteRule ^ https://pandadev.site%{REQUEST_URI} [R=302,L,NE]

  # Force HTTPS, while respecting HTTPS terminated by a trusted proxy/CDN.
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP:X-Forwarded-Proto} !^https$ [NC]
  RewriteRule ^ https://pandadev.site%{REQUEST_URI} [R=302,L,NE]

  # Never expose files stored in data/.
  RewriteRule ^data(?:/|$) - [F,END,NC]
</IfModule>

# Protect secrets and temporary files (Apache 2.4+).
<FilesMatch "^(\.env|\.htaccess|.*\.tmp)$">
  <IfModule mod_authz_core.c>
    Require all denied
  </IfModule>
  <IfModule !mod_authz_core.c>
    Order allow,deny
    Deny from all
  </IfModule>
</FilesMatch>

# Correct MIME type for direct .mobileconfig links (download.php also sets headers).
<IfModule mod_mime.c>
  AddType application/x-apple-aspen-config .mobileconfig
</IfModule>
