# ============================================================
#  FunAI — Bảo vệ thư mục Trang Quản Trị
#  Chặn tải trực tiếp các file nhật ký/cache/cấu hình nhạy cảm.
#  (PHP vẫn chạy bình thường; manifest.json vẫn mở cho PWA.)
# ============================================================

# Không liệt kê thư mục
Options -Indexes

# Chặn nhật ký & file dữ liệu thô (error_log.txt, *.log, *.sql, backup)
<FilesMatch "\.(txt|log|sql|bak|old|ini)$">
    Require all denied
</FilesMatch>

# Chặn đích danh các JSON nội bộ (KHÔNG chặn manifest.json — PWA cần)
<FilesMatch "^(settings|cws_cache)\.json$">
    Require all denied
</FilesMatch>

# Header bảo mật cơ bản & Chống Cache cho file quản trị (nếu mod_headers có sẵn)
<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"

    # Chống kẹt cache trình duyệt cho các file giao diện và dữ liệu quản trị
    <FilesMatch "\.(html|js|css|json)$">
        Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0"
        Header set Pragma "no-cache"
        Header set Expires "0"
    </FilesMatch>
</IfModule>
