2015-07-11 50 views
0

我想在我的服务器上设置Yii2高级模板前端工作,但后端有问题所有资产返回404错误。Yii2高级Apache重写

这是我的Apache 2的虚拟主机:

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> 

的 “...” 在这里,您可以路径短,请忽略它们。

此外后端是一个符号链接

任何想法?

此致敬礼, 保罗。

回答

0

好的,也许这也会帮助别人。

我所做的是我已经声明一个别名和另一个号码簿指令也需要一个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>