# 指尖云盘 · Apache 规则
# 版权归 指尖网络 所有

Options -Indexes
DirectoryIndex index.php index.html

<IfModule mod_rewrite.c>
    RewriteEngine On
    # 强制 HTTPS（如站点未启用证书请注释以下两行）
    # RewriteCond %{HTTPS} off
    # RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

    # 禁止访问程序内部目录
    RewriteRule ^(config|install|lib|partials|pm)/ - [F,L]
</IfModule>

# 禁止访问敏感文件
<FilesMatch "^(\.env.*|\.user\.ini|\.htaccess|\.htpasswd|composer\.(json|lock)|package(-lock)?\.json|README\.md|.*\.(sql|log|bak|old|tmp|sh)|nginx\.htaccess)$">
    Require all denied
</FilesMatch>

# 安全响应头
<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>

# 静态资源缓存
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 7 days"
    ExpiresByType application/javascript "access plus 7 days"
    ExpiresByType image/svg+xml "access plus 30 days"
    ExpiresByType image/png "access plus 30 days"
    ExpiresByType image/jpeg "access plus 30 days"
</IfModule>
