-
Notifications
You must be signed in to change notification settings - Fork 255
/
Copy pathhtaccess.txt
179 lines (157 loc) · 5.57 KB
/
htaccess.txt
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
# ======================= Apache Yii2通用后台 二级域名配置 =================================
.env 配置:
# Urls
# ---------
FRONTEND_URL = /
BACKEND_URL = /
STORAGE_URL = /
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "E:\yii2admin\backend\web"
ServerName admin.yii2.cn
ErrorLog "logs/yii2.cn-error.log"
CustomLog "logs/yii2.cn-access.log" common
</VirtualHost>
<Directory "E:\yii2admin\backend\web">
AllowOverride all
Require all granted
</Directory>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "E:\yii2admin\frontend\web"
ServerName www.yii2.cn
ErrorLog "logs/yii2.cn-error.log"
CustomLog "logs/yii2.cn-access.log" common
</VirtualHost>
<Directory "E:\yii2admin\frontend\web">
AllowOverride all
Require all granted
</Directory>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "E:\yii2admin\storage\web"
ServerName storage.yii2.cn
ErrorLog "logs/yii2.cn-error.log"
CustomLog "logs/yii2.cn-access.log" common
</VirtualHost>
<Directory "E:\yii2admin\storage\web">
AllowOverride all
Require all granted
</Directory>
<Directory "E:\yii2admin/frontend/web">
RewriteEngine on
# 如果一个目录或一个文件存在,请直接使用请求
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# 否则去请求 index.php
RewriteRule . index.php
Require all granted
</Directory>
<Directory "E:\yii2admin/backend/web">
RewriteEngine on
# 如果一个目录或一个文件存在,请直接使用请求
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# 否则去请求 index.php
RewriteRule . index.php
Require all granted
</Directory>
<Directory "E:\yii2admin/storage/web">
RewriteEngine on
# 如果一个目录或一个文件存在,请直接使用请求
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# 否则去请求 index.php
RewriteRule . index.php
Require all granted
</Directory>
# ======================= Apache Yii2通用后台 单域名配置=================================
.env 配置:
# Urls
# ---------
FRONTEND_URL = /
BACKEND_URL = /admin
STORAGE_URL = /storage/web
<VirtualHost *:80>
ServerName www.yii2.cn
RewriteEngine on
DocumentRoot E:\yii2admin
# 应用前端主要重写规则
RewriteCond %{HTTP_HOST} ^www.yii2.cn$ [NC]
RewriteCond %{REQUEST_URI} !^/(backend/web|admin|storage/web)
RewriteRule !^/frontend/web /frontend/web%{REQUEST_URI} [L]
# 重定向的网页没有一个斜线(注释,如果必要的话)
#RewriteCond %{REQUEST_URI} ^/admin/$
#RewriteRule ^(/admin)/ $1 [L,R=301]
# 禁止斜线重定向
RewriteCond %{REQUEST_URI} ^/admin$
RewriteRule ^/admin /backend/web/index.php [L]
# 后端应用程序的主要重写规则
RewriteCond %{REQUEST_URI} ^/admin
RewriteRule ^/admin(.*) /backend/web$1 [L]
<Directory />
Options FollowSymLinks
AllowOverride None
AddDefaultCharset utf-8
</Directory>
<Directory "E:\yii2admin/frontend/web">
RewriteEngine on
# 如果一个目录或一个文件存在,请直接使用请求
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# 否则去请求 index.php
RewriteRule . index.php
Require all granted
</Directory>
<Directory "E:\yii2admin/backend/web">
RewriteEngine on
# 如果一个目录或一个文件存在,请直接使用请求
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# 否则去请求 index.php
RewriteRule . index.php
Require all granted
</Directory>
<Directory "E:\yii2admin/storage/web">
RewriteEngine on
# 如果一个目录或一个文件存在,请直接使用请求
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# 否则去请求 index.php
RewriteRule . index.php
Require all granted
</Directory>
<FilesMatch \.(env|htaccess|htpasswd|svn|git)>
Require all denied
</FilesMatch>
</VirtualHost>
# ======================= Apache Yii2通用后台 二级目录配置=================================
yii2admin目录:E:\www\yii2admin
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "E:\www"
ServerName www.yii.cn
ErrorLog "logs/yii.cn-error.log"
CustomLog "logs/yii.cn-access.log" common
</VirtualHost>
<Directory "E:\www">
AllowOverride all
Require all granted
</Directory>
<Directory "E:\www/yii2admin/backend/web">
RewriteEngine on
# 如果一个目录或一个文件存在,请直接使用请求
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# 否则去请求 index.php
RewriteRule . index.php
Require all granted
</Directory>
后台:www.yii.cn/yii2admin/backend/web/
前台:www.yii.cn/yii2admin/frontend/web/
.env 配置:
# Urls
# ---------
FRONTEND_URL = /yii2admin/frontend/web
BACKEND_URL = /yii2admin/backend/web
STORAGE_URL = /yii2admin/storage/web