-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.htaccess
More file actions
133 lines (121 loc) · 7.16 KB
/
Copy path.htaccess
File metadata and controls
133 lines (121 loc) · 7.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Запрет directory listing (сканеры ругаются на открытый /images/ и т.п.).
# Если AllowOverride не даёт Options — продублируй Options -Indexes в vhost Apache.
Options -Indexes
# Страницы ошибок (deep blue, папка /errors/). Только локальные пути —
# полный https:// в ErrorDocument превращает ответ в редирект (302).
ErrorDocument 400 /errors/400.html
ErrorDocument 401 /errors/401.html
ErrorDocument 402 /errors/error.html
ErrorDocument 403 /errors/403.html
ErrorDocument 404 /errors/404.html
ErrorDocument 405 /errors/error.html
ErrorDocument 406 /errors/error.html
ErrorDocument 407 /errors/error.html
ErrorDocument 408 /errors/error.html
ErrorDocument 500 /errors/500.html
ErrorDocument 502 /errors/502.html
ErrorDocument 503 /errors/503.html
ErrorDocument 504 /errors/504.html
# =============================================================================
# Безопасность: листинг выкл.; чувствительное не скачивается.
# Разрешено по HTTP: PHP-вход (index.php и т.п.), картинки, css/js/шрифты,
# errors/*.html, robots.txt. Демки — только через getdemo.php (см. demos/).
# =============================================================================
<IfModule mod_authz_core.c>
# Бэкапы, дампы, архивы, шаблоны Smarty, логи, env
<FilesMatch "(?i)\.(sql|bak|old|orig|save|swp|dist|env|log|yml|yaml|phar|zip|rar|7z|tar|gz|tgz|bz2|tpl|md)$">
Require all denied
</FilesMatch>
# Конфиг и служебные файлы в корне (include по FS работает, HTTP — 403)
<FilesMatch "(?i)^(config\.php|init\.php|composer\.(json|lock)|package(-lock)?\.json|requirements\.txt|\.gitignore|\.gitattributes|sb_debug_connection\.php)$">
Require all denied
</FilesMatch>
</IfModule>
<IfModule !mod_authz_core.c>
<FilesMatch "(?i)\.(sql|bak|old|orig|save|swp|dist|env|log|yml|yaml|phar|zip|rar|7z|tar|gz|tgz|bz2|tpl|md)$">
Order allow,deny
Deny from all
</FilesMatch>
<FilesMatch "(?i)^(config\.php|init\.php|composer\.(json|lock)|package(-lock)?\.json|requirements\.txt|\.gitignore|\.gitattributes|sb_debug_connection\.php)$">
Order allow,deny
Deny from all
</FilesMatch>
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
# Прокинуть Authorization в PHP (иначе CGI/Apache часто глотает Bearer).
RewriteCond %{HTTP:Authorization} .
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Блокировка AI/мусорных ботов.
# НЕ блокируем поисковики и SEO-аудиторы (Google/Yandex/Bing/Semrush/Ahrefs/DataForSeo/
# facebookexternalhit/Twitterbot) — иначе сканеры пишут «canonical/OG не найден».
RewriteCond %{HTTP_USER_AGENT} (Amazonbot|GPTBot|GPT-Bot|DotBot|MJ12bot|Bytespider|CCBot|ClaudeBot|Claude-Web) [NC]
RewriteRule .* - [F,L]
# Блокировка страницы Edit Permissions (Material Admin 1.1.5.4)
# Предотвращает перезапись прав групп через p=admin&c=admins&o=editpermissions
RewriteCond %{QUERY_STRING} (^|&)c=admins(&|$) [NC]
RewriteCond %{QUERY_STRING} (^|&)o=editpermissions(&|$) [NC]
RewriteRule ^index\.php$ - [F,L]
# ЧПУ: /banlist → index.php?p=banlist, /admin/bans → index.php?p=admin&c=bans
# Если панель в подпапке — раскомментируй: RewriteBase /подпапка/
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Старые Location/JS: /admin/index.php?p=… → корневой index.php (не путать с /admin/menu)
RewriteRule ^admin/index\.php$ index.php [L,QSA]
# /admin/recidivism/STEAM_0-0-123 (двоеточия → дефисы)
RewriteRule ^admin/(recidivism|parsec)/(STEAM_[0-9]+-[01]-[0-9]+)/?$ index.php?p=admin&c=$1&steam=$2 [L,QSA]
RewriteRule ^admin/([a-zA-Z0-9_]+)/?$ index.php?p=admin&c=$1 [L,QSA]
# /banlist/2 → page=2 (и то же для commslist)
RewriteRule ^(banlist|commslist)/([0-9]+)/?$ index.php?p=$1&page=$2 [L,QSA]
RewriteRule ^(login|logout|admin|submit|banlist|commslist|servers|protest|account|lostpassword|login2fa|home|search_bans|search_comm|pay|adminlist)/?$ index.php?p=$1 [L,QSA]
</IfModule>
# Сжатие HTML/CSS/JS + Vary (SEO-сканеры требуют Accept-Encoding при gzip)
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript application/json application/xml image/svg+xml
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept-Encoding
</IfModule>
# Security-заголовки
<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"
# 0 — правильно. "1; mode=block" устарело: XSS-фильтр браузеров убран, mode=block
# сам создавал уязвимости. Сканеры часто требуют mode=block по старым чеклистам — игнор.
Header always set X-XSS-Protection "0"
Header always set Permissions-Policy "geolocation=(), microphone=(), camera=(), payment=(), usb=()"
# allow-popups нужен для Steam OpenID / внешних окон; same-origin ломает логин.
Header always set Cross-Origin-Opener-Policy "same-origin-allow-popups"
Header always set Cross-Origin-Resource-Policy "same-site"
# COEP: require-corp сломает Steam/внешние картинки. unsafe-none = явный opt-out.
Header always set Cross-Origin-Embedder-Policy "unsafe-none"
# CSP: unsafe-inline/unsafe-eval обязательны (xajax, MooTools, Summernote, inline в теме).
# Убрать без nonce/hash-рефакторинга всего JS = развал админки. Не трогаем.
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: http:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'self'; base-uri 'self'; form-action 'self'; object-src 'none'"
Header unset X-Powered-By
</IfModule>
<IfModule mod_php7.c>
php_flag expose_php off
</IfModule>
# Кэширование статических файлов браузером
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 30 days"
ExpiresByType image/jpeg "access plus 30 days"
ExpiresByType image/gif "access plus 30 days"
ExpiresByType image/png "access plus 30 days"
ExpiresByType image/webp "access plus 30 days"
ExpiresByType image/svg+xml "access plus 30 days"
ExpiresByType image/x-icon "access plus 30 days"
ExpiresByType text/css "access plus 7 days"
ExpiresByType application/javascript "access plus 7 days"
ExpiresByType text/javascript "access plus 7 days"
ExpiresByType font/woff2 "access plus 30 days"
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\.(jpg|jpeg|png|gif|webp|svg|ico|css|js|woff2)$">
Header set Cache-Control "public, max-age=604800"
</FilesMatch>
</IfModule>