-
Notifications
You must be signed in to change notification settings - Fork 0
/
.htaccess_SAMPLE
219 lines (160 loc) · 6.07 KB
/
.htaccess_SAMPLE
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
############################################
## 默认 index 文件
DirectoryIndex index.php
<IfModule mod_php7.c>
############################################
## 调整PHP的内存以及执行时间
php_value memory_limit 756M
php_value max_execution_time 18000
############################################
## 在初始化自动加载之前禁用自动会话机制
php_flag session.auto_start off
############################################
## 启用html结果压缩
#php_flag zlib.output_compression on
###########################################
## 禁用用户代理验证以不中断多个图像上载
php_flag suhosin.session.cryptua off
</IfModule>
<IfModule mod_security.c>
###########################################
## 禁用后期处理以不中断多个图像上载
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
<IfModule mod_deflate.c>
############################################
## 启用apache服务的文件压缩(要求Apache 2.x以上版本)
## http://developer.yahoo.com/performance/rules.html#gzip
# 在所有内容上插入筛选器
SetOutputFilter DEFLATE
# 仅在选定内容类型上插入筛选器(要压缩的文件类型)
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript application/json image/svg+xml
# Netscape(网景浏览器) 4.x存在的问题...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape(网景浏览器) 4.06-4.08 存在的问题
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE 伪装 Netscape, 但属正常
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# 不压缩图像
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary # 仅图片不压缩
#SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|exe|t?gz|zip|bz2|sit|rar|pdf|mov|avi|mp3|mp4|rm)$ no-gzip dont-vary #设置不对压缩的文件
# 确保代理不会传递错误的内容
Header append Vary User-Agent env=!dont-vary
</IfModule>
<IfModule mod_ssl.c>
############################################
## 使HTTPS环境变量可用于CGI模式
SSLOptions StdEnvVars
</IfModule>
############################################
## 使用HHVM(或任何其他)通过ProxyPassMatch处理apache2.4.6 CentOS build的解决方法
## 请将其设置为虚拟主机配置级别
## SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
############################################
<IfModule mod_rewrite.c>
############################################
## 开启路由重写
Options +FollowSymLinks
RewriteEngine on
############################################
## 静态文件
# 非pub目录请求,且如果加上pub目录判断是文件,则重写到pub目录,重新请求这个文件
RewriteCond %{REQUEST_URI} !^/pub/.*$
RewriteCond %{DOCUMENT_ROOT}/pub/$1 -f
RewriteRule ^(.*)$ /pub/$1 [L]
RewriteCond %{THE_REQUEST} \s/pub/ [NC,OR]
############################################
## 可以设置你的代码目录位置
## 相对于根目录的路径
#RewriteBase /WelineFramework/
############################################
## CGI 环境中的 HTTP authorization授权方案
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
############################################
## 已禁用TRACE和TRACK HTTP方法以防止XSS攻击
RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
RewriteRule .* - [L,R=405]
############################################
## 针对移动手持用户代理的重定向
#RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$
#RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
#RewriteRule ^(.*)$ /mobiledirectoryhere/ [L,R=302]
############################################
## 从不重写现有文件、目录和链接
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
############################################
## 重写所有请求到index.php入口文件
RewriteRule .* index.php [L]
</IfModule>
############################################
## 防止编码引起的服务器重写问题
## 如果仍有问题,请使用第二行
AddDefaultCharset Off
#AddDefaultCharset UTF-8
AddType 'text/html; charset=UTF-8' html
<IfModule mod_expires.c>
############################################
## 添加header默认过期时间
ExpiresDefault "access plus 1 year"
ExpiresByType text/html A0
ExpiresByType text/plain A0
</IfModule>
###########################################
## 拒绝访问根目录下的文件访问以隐藏敏感的应用程序信息
RedirectMatch 403 /\.git
<Files composer.json>
Require all denied
</Files>
<Files composer.lock>
Require all denied
</Files>
<Files .gitignore>
Require all denied
</Files>
<Files .htaccess>
Require all denied
</Files>
<Files .htaccess.sample>
Require all denied
</Files>
<Files .php_cs.dist>
Require all denied
</Files>
<Files COPYING.txt>
Require all denied
</Files>
<Files LICENSE.txt>
Require all denied
</Files>
<Files LICENSE_AFL.txt>
Require all denied
</Files>
<Files nginx.conf.sample>
Require all denied
</Files>
<Files package.json>
Require all denied
</Files>
<Files php.ini.sample>
Require all denied
</Files>
<Files README.md>
Require all denied
</Files>
<Files .user.ini>
Require all denied
</Files>
# 对于应用程序未处理的404和403,返回纯404响应
ErrorDocument 404 /pub/errors/404.php
ErrorDocument 403 /pub/errors/404.php
<IfModule mod_headers.c>
Header set X-UA-Compatible "IE=edge"
# `mod_headers` 无法根据内容匹配时
# `X-UA-Compatible` 应该只响应HTML文档文本内容,而非其他资源
<FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
Header unset X-UA-Compatible
</FilesMatch>
</IfModule>