2016-11-12 14 views
-1

私が現在働いている会社は、symfony 2.8に基づいて3年以上のライブサイトを持っています。最近、新しい顧客にテストするために導入されました。オリジナルの画像は、 "/bundles/bundlename/images/image.png"のようにhtmlでアクセスされます。なぜこの書き換えは使えないのですか?

しかし、お客様のサーバーではすべてがサブフォルダの下にあるため、画像のURLは "/d2s/bundles/bundlename/images/image.png"のようにする必要があります。他のすべての部品がすべてに設定されているのapacheのconfのバーチャルホストのAllowOverrideで、正常に動作し

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] 

    [,,,] 

: は、私たちは、このようなプロジェクトのWebディレクトリ内の.htaccessファイルを持っています。しかし、このURL書き直しはうまくいきません。まったくなかったかのように。

何が間違っている可能性がありますか?

+0

私は単なる概念的な誤りがあることを知りました。アプリケーション全体がサブフォルダ(/ d2s /)にあるので、/ bundle /への呼び出しはアプリケーションのdocrootに到達せず、.htaccessにも到達しません。私が何を入れても、それはこの方法ではうまくいきません。 司会者がこの嘆願書を読んでこの質問を閉じると! – posthy

答えて

0

正しいRewriteBaseを設定してください。内部RewriteRuleパターンまたは置換を/で開始しないでください。 RewriteBaseに相当するものを自動判定する場合は、他のすべてのルールの前に置く必要があります。

関連する問題