# ============================================================
#  The Sinigaglia Heritage
# ============================================================

# ---- 1. 入口指向密码门（index.php），而不是内容页 ----
DirectoryIndex index.php

# ---- 2. 保护内容页与配置文件，禁止直接访问 ----
# 内容页 heritage.php 自带 PHP 守卫（未登录会 302 回 index.php），
# 这里再加一层，让它连 302 都不会出现。
<Files "heritage.php">
  <IfModule mod_authz_core.c>
    Require all denied
  </IfModule>
  <IfModule !mod_authz_core.c>
    Order allow,deny
    Deny from all
  </IfModule>
</Files>

# 配置文件与密码工具一律不可直访
<FilesMatch "^(gate-config\.php|set-password\.php)$">
  <IfModule mod_authz_core.c>
    Require all denied
  </IfModule>
  <IfModule !mod_authz_core.c>
    Order allow,deny
    Deny from all
  </IfModule>
</FilesMatch>

<IfModule mod_rewrite.c>
  RewriteEngine On
  # 兜底：任何对内容文件的直接请求都拦掉
  RewriteRule ^heritage\.(php|dat|html)$ - [F,L]
</IfModule>

# ---- 3. 禁止目录列表 ----
Options -Indexes

# ---- 4. 安全响应头 ----
<IfModule mod_headers.c>
  Header always set X-Content-Type-Options "nosniff"
  Header always set X-Frame-Options "SAMEORIGIN"
  Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>
