-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.htaccess
377 lines (313 loc) · 25.4 KB
/
.htaccess
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# Этот .htaccess поможет сделать ваш сайт быстрей.
# Пользуйтесь на здоровье себе и вашему сайту.
# Автор: Александр Белов aka alex Roosso
# Сайт: http://www.black-web.ru
# ICQ: 3405729
# Электропочта: [email protected]
Options All -ExecCGI +Includes +FollowSymLinks
#Options -MultiViews
# REWRITE ___________________
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# и запрошенный путь не соответствует пути к физической папке
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule customers/registration/$ controllers/customers/roomRegistration.php [L,QSA]
# и запрошенный путь соответствует пути к физическому файлу
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) web/app.php?path=$1 [L,QSA]
#RewriteCond %{HTTP_HOST} ^allseervice.in.ua
#RewriteRule (.*) http://allseervice.in.ua/$1 [R=301,L]
#RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
#RewriteRule ^index\.html$ http://allseervice.in.ua/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule photos/(.+)\.jpg$ photos/0001.jpg [L,QSA]
RewriteCond %{REQUEST_FILENAME} !(index\.html)
# только для htm файлов
RewriteCond %{REQUEST_FILENAME} (\.html)
RewriteCond %{REQUEST_FILENAME} !(\.+)(\.php)(\.*)
RewriteCond %{HTTP_REFERER} ^$
RewriteCond %{HTTP_X_REQUESTED_WITH} ^$
RewriteCond %{HTTP_X_REQUESTED_WITH} !(xmlhttprequest)
RewriteRule .htm$ index.html [L,QSA]
# и запрошенный путь не соответствует пути к физическому файлу
RewriteCond %{REQUEST_FILENAME} !-f
# и запрошенный путь не соответствует пути к физической папке
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} !^/video_site/
RewriteCond %{REQUEST_FILENAME} !(.php)
# то перенаправить запрос на главную страницу index.html
RewriteRule .htm* index.html [L]
RewriteCond %{REQUEST_FILENAME} (\.+)(\.go)(\.*)
RewriteRule (.*)\.go go.php?program=$1 [L]
</IfModule>
AddType application/octet-stream .zip
AddType application/octet-stream .mp3
AddType application/text/csv .csv
# REDIRICT __________________
# 301 простой редерикт
# Redirect 301 /index.html /index.php
# http://www.roocms.com - URL На который мы перенаправляем запросы
# Полезно в случаях когда надо полностью перенаправлять людей с одного сайта на другой.
# Redirect / http://www.roocms.com
<IfModule mod_rewrite.c>
# RewriteRule ^news/([^/\.]+)/?$ news.php?news=$1 [L]
# RewriteRule ^(.*\.((js)|(css)))$ plugin/GzipFile.php?file=$1 [QSA,NE,L]
# RewriteRule \.css$ plugin/GzipFile.php?file=$1
# RewriteRule \.js$ plugin/GzipFile.php?file=$1
# Круглые скобки () используются для выделения групп символов. В дальнейшем к ним можно обращаться по номеру.
# Символ ^ обозначает начало строки.
# Символ $ обозначает конец строки.
# Символ . обозначает любой символ.
# Символ | обозначает альтернативу. Например, выражения "A|B" означают "A или B".
# Символ ? ставится после символа (группы), который может как присутствовать, так и отсутствовать.
# Символ * ставится после символа (группы), который может отсутствовать или присутствовать неограниченное число раз подряд.
# Символ + действует аналогично символу * с той лишь разницей, что предшествующий ему символ обязательно должен присутствовать хотя бы один раз.
# Квадратные скобки [] используются для перечисления допустимых символов.
# Квадратные скобки [^] используются для перечисления недоступных символов.
# Символ \ ставится перед спецсимволами, если они нужны в своем первозданном виде.
# Все, что расположено после символа '#', считается комментарием.
</IfModule>
# RedirectMatch 301 /blog(.*) http://www.roocms.com/blog$1
# SECURE ____________________
<IfModule mod_ssl.c>
# SSLOptions +StrictRequire
# SSLRequireSSL
# SSLRequire %{HTTP_HOST} eq "iblog.su"
</IfModule>
<IfModule mod_rewrite.c>
# RewriteCond %{HTTPS} !on
# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
# RewriteCond %{SERVER_PORT} !^443
# RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# $n - (0 <= n <= 9) предоставляющие доступ к сгруппированным частям (в круглых скобках!) шаблона из соответствующей директивы RewriteRule (единственной, следующей сразу за текущим набором директив RewriteCond).
# %n - (1 <= n <= 9) предоставляющие доступ к сгруппированным частям (в круглых скобках!) шаблона из соответствующей директивы RewriteCond в текущем наборе условий.
# %{NAME_OF_VARIABLE} - где NAME_OF_VARIABLE может быть одной из ниже приведенных переменных
# HTTP_USER_AGENT Содержит информацию о типе и версии браузера и операционной системы посетителя.
# HTTP_REFERER Приводится адрес страницы, с которой посетитель пришёл на данную страницу.
# HTTP_COOKIE Список COOKIE, передаваемых браузером
# HTTP_FORWARDED Страница непосредственно, с которой перешел пользователь
# HTTP_HOST Адрес сервера, например, roocms.com
# HTTP_ACCEPT Описываются предпочтения клиента относительно типа документа.
# REMOTE_ADDR IP-адрес посетителя.
# REMOTE_HOST адрес посетителя в нормальной форме — например, 23.beeline.ru
# REMOTE_IDENT Имя удаленного пользователя. Имеет формат имя.хост, например, starter.www.rutt.net.ru
# REMOTE_USER Тоже, что и REMOTE_IDENT, но содержит только имя. Пример: starter
# REQUEST_METHOD Позволяет определить тип запроса (GET или POST). Должен обязательно анализироваться, т.к. определяет дальнейший способ обработки информации
# SCRIPT_FILENAME Полный путь к веб-странице на сервере.
# PATH_INFO Содержит в себе все, что передавалось в скрипт.
# QUERY_STRING Содержит строчку, переданную в качестве запроса при вызове CGI скрипта.
# AUTH_TYPE Используется для идентификации пользователя
# DOCUMENT_ROOT Cодержит путь к корневой директории сервера.
# SERVER_ADMIN Почтовый адрес владельца сервера, указанный при установке.
# SERVER_NAME Адрес сервера, типа idea.roocms.com
# SERVER_ADDR IP-адрес вашего сайта.
# SERVER_PORT Порт, на котором работает Apache.
# SERVER_PROTOCOL Версия HTTP протокола.
# SERVER_SOFTWARE Название сервера, например, Apache/1.3.2 (Unix)
# TIME_YEAR TIME_MON TIME_DAY TIME_HOUR TIME_MIN TIME_SEC TIME_WDAY TIME
# Переменные предназначены для работы со временем в разных форматах.
# API_VERSION Это версия API модуля Apache (внутренний интерфейс между сервером и модулем) в текущей сборке сервера, что определено в include/ap_mmn.h.
# THE_REQUEST Полная строка HTTP запроса отправленная браузером серверу (т.е., «GET /index.html HTTP/1.1»). Она не включает какие-либо дополнительные заголовки отправляемые браузером.
# REQUEST_URI Ресурс, запрошенный в строке HTTP запроса.
# REQUEST_FILENAME Полный путь в файловой системе сервера к файлу или скрипту соответствующим этому запросу.
# IS_SUBREQ Будет содержать текст «true» если запрос выполняется в текущий момент как подзапрос, «false» в другом случае. Подзапросы могут быть сгенерированы модулями которым нужно иметь дело с дополнительными файлами или URI для того чтобы выполнить собственные задачи.
# Внимание!
# Данная конфигурация файла может порождать побочные запросы к индексному файлу вашего сайта
# в случаях когда в вашей верстке или скриптах содержаться ошибки или ссылки на несуществующие файлы или папки.
# Подобные обращения в большом числе могут вызвать нагрузку на ваш веб сервер. 1 ошибка = 1 лишнему обращению.
# Будьте внимательны. Перед использованием данного файла проверьте файлы access.log и error.log сгенерированные вашим Apache сервером.
# Если вы обнуружите ошибки в ваших скриптах, исправьте их перед использованием на "боевом сервере"
# Блокировать любой запрос, пытающийся испортить base64_encode через URL
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Блокировать любой запрос, содержащий тег <script> в URL
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Блокировать любой запрос, пытающийся установить значение глобальных переменных PHP через URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Блокировать любой запрос, пытающийся изменить _REQUEST переменную через URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Перенаправлять заблокированные запросы
RewriteRule .* index.htm [F]
#RedirectMatch 301 regexp /error410.html
</IfModule>
# HOTLINKING ________________
<IfModule mod_rewrite.c>
# RewriteCond %{HTTP_REFERER} !^$
# RewriteCond %{HTTP_REFERER} !^http://([ -a-z0-9] \.)?ibog\.su [NC]
# RewriteRule \.(gif|jpe?g|png)$ - [F,NC,L]
</IfModule>
# HANDLER ___________________
#AddHandler application/x-httpd-php .html
AddHandler cgi-script .pl .py .jsp .asp .shtml .sh .cgi
AddType application/x-javascript .js
AddType application/json .json
AddType text/css .css
AddType text/xml .xml
# Audio
AddType audio/ogg .oga .ogg
AddType audio/mp4 .m4a .f4a .f4b
# Video
AddType video/ogg .ogv
AddType video/mp4 .mp4 .m4v .f4v .f4p
AddType video/webm .webm
AddType video/x-flv .flv
# SVG
AddType image/svg+xml .svg .svgz
AddEncoding gzip .svgz
# Webfonts
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf .ttc
AddType font/opentype .otf
AddType application/x-font-woff .woff
# Assorted types
AddType image/x-icon .ico
AddType image/webp .webp
AddType text/cache-manifest .appcache .manifest
AddType text/x-component .htc
AddType application/xml .rss .atom .xml .rdf
AddType application/x-chrome-extension .crx
AddType application/x-opera-extension .oex
AddType application/x-xpinstall .xpi
AddType application/octet-stream .safariextz
AddType application/x-web-app-manifest+json .webapp
AddType text/x-vcard .vcf
AddType application/x-shockwave-flash .swf
AddType text/vtt .vtt
AddType application/octet-stream .doc .mov .avi .pdf .xls .rar .zip .mp3 .wmv .ppt .tar .gz .docx .xlsx
# ForceType application/x-httpd-php
# INDEX FILE ________________
DirectoryIndex index.php
# GZIP ______________________
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include mime ^text\.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_include mime ^application/x-font-woff.*
mod_gzip_item_exclude mime ^image\.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
<ifModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript application/x-font-woff image/jpg image/jpeg
</ifModule>
# PHP _______________________
php_value upload_max_filesize 32M
php_value post_max_size 32M
php_value default_charset utf-8
php_flag magic_quotes_gpc Off
php_flag register_globals Off
php_flag short_open_tag On
# php_value max_input_time 200
# php_value session.name sid
php_value error_reporting 0
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_flag log_errors off
php_flag ignore_repeated_errors on
php_flag ignore_repeated_source on
# php_value log_errors_max_len 1024
php_flag report_memleaks off
php_flag track_errors off
php_value docref_root 0
php_value docref_ext 0
# php_value error_log /tmp/php_error.log
# php_value error_prepend_string " "
# php_value error_append_string " "
<Files php_error.log>
Order allow,deny
Deny from all
Satisfy All
</Files>
<IfModule php5_module>
# php_value session.cookie_httponly true
</IfModule>
# XDEBUG ___________________
# Настройки для расширения XDebug
#php_flag xdebug.profiler_enable On
#php_flag xdebug.extended_info On
#php_flag xdebug.remote_enable off
#php_flag xdebug.auto_trace off
# OTHER SETTINGS ____________
<IfModule mod_setenvif.c>
SetEnv TZ Europe/Moscow
</IfModule>
ServerSignature Off
# AddDefaultCharset UTF-8
# AddCharset utf-8 .atom .css .js .json .rss .vtt .xml
# CACHE AND Headers _________
<ifModule mod_headers.c>
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>
<FilesMatch "\.(js|css|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
<FilesMatch "\.(flv|swf|ico|gif|jpg|jpeg|png|jpe?g)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control
</FilesMatch>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
<FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|oex|xpi|safariextz|vcf)$" >
Header unset X-UA-Compatible
</FilesMatch>
</IfModule>
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 604800 seconds"
ExpiresByType application/javascript "access plus 604800 seconds"
ExpiresByType application/x-javascript "access plus 604800 seconds"
ExpiresByType text/html "access plus 43200 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
ExpiresByType text/xml "access plus 600 seconds"
ExpiresByType application/xml "access plus 600 seconds"
ExpiresByType application/json "access plus 600 seconds"
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType text/x-component "access plus 1 week"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
</ifModule>
# Bad Rquest
ErrorDocument 400 /index.php?page=e400
# Authorization Required
ErrorDocument 401 /index.php?page=e401
# Forbidden
ErrorDocument 403 /index.htm?page=e403
# Not found
ErrorDocument 404 /index.htm?page=e404
# Method Not Allowed
ErrorDocument 405 /index.php?page=e405
# Request Timed Out
ErrorDocument 408 /index.php?page=e408
# Request URI Too Long
ErrorDocument 414 /index.php?page=notfound
# Internal Server Erro
ErrorDocument 500 /index.php?page=notfound
# Not Implemented
ErrorDocument 501 /index.php?page=notfound
# Bad Gateway
ErrorDocument 502 /index.php?page=notfound
# Service Unavailable
ErrorDocument 503 /index.php?page=notfound
# Gateway Timeout
ErrorDocument 504 /index.php?page=notfound