1
从单域:http://www.yiiframework.com/wiki/799/yii2-app-advanced-on-single-domain-apache-nginx/#hh2配置Yii2高级与多个后端
它的工作原理,但我已经创造了另一个后端。
这是.htaccess
配置,我有:
RewriteEngine On
# End the processing, if a rewrite already occurred
RewriteRule ^(frontend|backend2)/web/ - [L]
RewriteRule ^(frontend|backend)/web/ - [L]
# Handle the case of backend, skip ([S=1]) the following rule, if current matched
RewriteRule ^backend(/(.*))?$ backend/web/$2 [S=1]
RewriteRule ^backend2(/(.*))?$ backend2/web/$3 [S=2]
# 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
最终前端网址:http:// example.com/
- >确定。
最终后端网址:http:// example.com/backend
- >错误404
最终另一个后端URL:http:// example.com/backend2
- >确定。
为什么'S'标志?在这两种情况下都使用[L]。 – Bizley
什么是[L]?我不知道。我正在学习Yii2。帮助我 – user3318842
'L'表示最后一个,所以当这个规则匹配时,它停止处理其他规则。这不是Yii 2的问题,它是Apache重写模块 - 请参阅https://httpd.apache.org/docs/2.4/rewrite/flags.html – Bizley