2016-11-12 37 views
-1

我目前工作的公司有一個基於symfony 2.8的3年以上的現場網站。最近它被部署用於測試新客戶。原始圖像通過html訪問,如「/bundles/bundlename/images/image.png」。爲什麼沒有這個重寫過程?

然而,在客戶服務器上,整個事情都在一個子文件夾下,所以image url應該像「/d2s/bundles/bundlename/images/image.png」。 我們有這樣的項目的web目錄.htaccess文件:

DirectoryIndex app.php 
<IfModule mod_rewrite.c> 
    RewriteEngine On 
    FollowSymLinks On 

    RewriteRule /?bundles/(.*)$ /d2s/bundles/$1 [NC,R=301,L] 

    # Determine the RewriteBase automatically and set it as environment variable. 
    # If you are using Apache aliases to do mass virtual hosting or installed the 
    # project in a subdirectory, the base path will be prepended to allow proper 
    # resolution of the app.php file and to redirect to the correct URI. It will 
    # work in environments without path prefix as well, providing a safe, one-size 
    # fits all solution. But as you do not need it in this case, you can comment 
    # the following 2 lines to eliminate the overhead. 
    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ 
    RewriteRule ^(.*) - [E=BASE:%1] 

    [,,,] 

所有其它部件做工精細,在阿帕奇的conf的虛擬主機的AllowOverride設置爲所有。但是,這個URL重寫不起作用,就像它根本不存在一樣。

任何想法可能是錯誤的?

+0

我剛剛意識到我提出了一個概念錯誤。由於整個應用程序位於子文件夾(/ d2s /)中,因此對/ bundles /的調用永遠不會到達應用程序的文檔根目錄,因此也不會到達.htaccess。無論我把它放在它不會這樣工作.. 如果版主讀這個請求關閉這個問題! – posthy

回答

0

設置正確的RewriteBase。請勿使用/開始內部重寫規則模式或替換。如果您要堅持使用RewriteBase等價物的自動確定,則應該先於所有其他規則。