2015-07-11 53 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>