我尝试在我的服务器上设置Yii2高级模板,前端有效,但后端出现问题,所有资产都返回404错误。
这是我的Apache 2 vhost:
DocumentRoot /var/www/.../frontend/web
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/.../frontend/web/>
Options Indexes +FollowSymLinks MultiViews
AllowOverride All
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/backend [NC]
RewriteRule . backend/index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Order allow,deny
allow from all
</Directory>
&#34; ...&#34;是为了缩短路径,请忽略它们。
后端也是符号链接
有什么想法吗?
祝你好运, 保罗。
答案 0 :(得分:0)
好的,也许这对其他人也有帮助。
我所做的是我已经声明了一个Alias和另一个Directory指令,还需要一个RewriteBase声明来实现它。
<Directory /var/www/.../www/frontend/web/>
Options Indexes +FollowSymLinks MultiViews
AllowOverride All
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
Order allow,deny
allow from all
</Directory>
Alias /backend /var/www/.../backend/web/
<Directory /var/www/.../backend/web/>
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
RewriteEngine on
RewriteBase /backend
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Order allow,deny
allow from all
</Directory>