yii2前后台使用同一域名

.htaccess配置如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
RewriteEngine On



RewriteRule ^(frontend|admin)/web/ -

# Handle the case of backend, skip ([S=1]) the following rule, if current matched

RewriteRule ^admin(/(.*))?$ backend/web/$2 [S=1]

# handle the case of frontend

RewriteRule .* frontend/web/$0


# Uncomment the following, if you want speaking URL

#RewriteCond %{REQUEST_FILENAME} !-f

#RewriteCond %{REQUEST_FILENAME} !-d

#RewriteRule ^([^/]+/web)/.*$ $1/index.php