# ============================================================
# 奇点CMS - Apache .htaccess（仅 Apache 生效）
#
# Nginx 环境请使用同目录下的 nginx.conf 配置片段：
#   在 Nginx server { } 块内 include /path/to/cms/nginx.conf;
#   或将 nginx.conf 内容手动粘贴到网站配置中。
# ============================================================

# 禁止直接访问敏感文件
<FilesMatch "\.(sql|md|lock|json|log|dat|tmp)$">
    Order allow,deny
    Deny from all
</FilesMatch>

# 禁止直接访问自动生成的配置文件
<FilesMatch "(generated\.php|generated\.example\.php)$">
    Order allow,deny
    Deny from all
</FilesMatch>

# 禁止直接访问号码池密钥文件
<FilesMatch "^\.pool_key$">
    Order allow,deny
    Deny from all
</FilesMatch>

# 禁止直接访问 data 目录（含加密号码库、知识库 schema 等）
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^data/ - [F,L]
</IfModule>

# 回退：无 mod_rewrite 时用 FilesMatch 保护 data 目录下文件
<DirectoryMatch "^.*/data/?$">
    Order allow,deny
    Deny from all
</DirectoryMatch>

# 禁止直接访问 includes 目录
<IfModule mod_rewrite.c>
    RewriteRule ^includes/ - [F,L]
</IfModule>

# ============================================================
# 图片加速器 - 静态图片长期缓存头
# 对 uploads/ 目录下的图片文件设置 30 天浏览器缓存
# ============================================================
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpeg "access plus 30 days"
    ExpiresByType image/png "access plus 30 days"
    ExpiresByType image/gif "access plus 30 days"
    ExpiresByType image/webp "access plus 30 days"
    ExpiresByType image/svg+xml "access plus 30 days"
</IfModule>
<IfModule mod_headers.c>
    <FilesMatch "\.(jpg|jpeg|png|gif|webp|svg)$">
        Header set Cache-Control "public, max-age=2592000"
    </FilesMatch>
</IfModule>

