# 面试管理系统 Apache 配置
# 启用 Rewrite 引擎
RewriteEngine On
RewriteBase /
# 如果请求文件不存在,重定向到 index.html
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
# MIME 类型设置
# JavaScript
AddType application/javascript js
AddType application/json json
# Fonts
AddType font/woff woff
AddType font/woff2 woff2
AddType font/ttf ttf
AddType application/vnd.ms-fontobject eot
# Images
AddType image/svg+xml svg svgz
# 启用 Gzip 压缩
# HTML, CSS, JavaScript, Text, XML
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json application/xml
# 设置缓存
ExpiresActive On
# 图片缓存 1 年
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
# CSS 和 JavaScript 缓存 1 年
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType application/json "access plus 1 year"
# 字体文件缓存 1 年
ExpiresByType font/woff "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
# HTML 不缓存
ExpiresByType text/html "access plus 0 seconds"
# 安全头设置
# X-Frame-Options
Header always set X-Frame-Options "SAMEORIGIN"
# X-Content-Type-Options
Header always set X-Content-Type-Options "nosniff"
# X-XSS-Protection
Header always set X-XSS-Protection "1; mode=block"
# Content-Security-Policy(根据实际情况调整)
Header always set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:"
# 禁止访问隐藏文件
Order allow,deny
Deny from all
# 禁止访问特定文件
Order allow,deny
Deny from all
# 错误页面(可选)
ErrorDocument 404 /index.html