2016-11-11 103 views
0

我有一個網站,比如www.example.com。所以當我訪問「http://www.example.com/program/resources/foo.gif」它服務我foo.gif圖像從/usr/share/roundcube/program/resources/foo.gif,我發現在訪問日誌。將單個圖像從一個目錄重定向到另一個目錄

所以我想要做的是,我想該圖像從/usr/share/roundcube/program/resources/複製到我的根目錄/var/www/www.example.com/webroot/img/寫重寫規則,這樣,當請求到來的foo.gif,應該從/var/www/www.example.com/webroot/img服務不是從/usr/share/roundcube/program/resources/

我已經試過這

RewriteEngine On 
RewriteRule /program/resources/(.*) /img/$1 [L] 

它的正常工作。但是,如果我想要制定一個單一圖像的規則是foo.gif

+0

而不是'。*'模式,把文件名:'foo \ .gif'。 – hjpotter92

+0

@ hjpotter92不,它不起作用。它給我404錯誤 – Rahul

回答

1

你可以使它更通用,更簡單。

RewriteEngine On 
RewriteCond %{DOCUMENT_ROOT}/override%{REQUEST_URI} -f 
RewriteRule .* override/$0 [L,NS] 

現在只是把你任何文件要來自RoundCube到覆蓋文件夾中,例如override/program/resources/foo.gif

相關問題