| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- # 面试管理系统 Apache 配置
- # 启用 Rewrite 引擎
- <IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteBase /
-
- # 如果请求文件不存在,重定向到 index.html
- RewriteRule ^index\.html$ - [L]
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule . /index.html [L]
- </IfModule>
- # MIME 类型设置
- <IfModule mod_mime.c>
- # 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
- </IfModule>
- # 启用 Gzip 压缩
- <IfModule mod_deflate.c>
- # HTML, CSS, JavaScript, Text, XML
- AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json application/xml
- </IfModule>
- # 设置缓存
- <IfModule mod_expires.c>
- 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"
- </IfModule>
- # 安全头设置
- <IfModule mod_headers.c>
- # 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:"
- </IfModule>
- # 禁止访问隐藏文件
- <FilesMatch "^\.">
- Order allow,deny
- Deny from all
- </FilesMatch>
- # 禁止访问特定文件
- <FilesMatch "(\.git|\.svn)">
- Order allow,deny
- Deny from all
- </FilesMatch>
- # 错误页面(可选)
- ErrorDocument 404 /index.html
|