我有我使用的圖像和其他類型的文件的模板系統,所以這裏是幾個模板樣本,他們的形象mod_rewrite的,尋找不存在的文件在不同的文件夾
/templates/template1/images/image1.jpg
/templates/template1/images/header/red/new/image1.jpg
/templates/template1/image2.jpg
/templates/template2/images/image2.jpg
/templates/template2/image2.jpg
現在,有時候模板會丟失圖片或文件,在這種情況下,我希望將用戶重定向到「默認」模板,同時保留url的其餘部分。
所以對於例子給出的,如果圖像中沒有找到用戶應該被重定向到
/templates/default/images/image1.jpg
/templates/default/images/header/red/new/image1.jpg
/templates/default/image2.jpg
/templates/default/images/image2.jpg
/templates/default/image2.jpg
這是我在做這項工作的嘗試,它在虛擬主機文件的定義
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/templates/default/(.*)$
RewriteRule ^/templates/(.*)/(.*) /templates/default/$2 [R]
現在這個
重定向/templates/template1/images/image1.jpg到/templates/default/image1.jpg,然後拋出500錯誤。
我在這裏做錯了什麼?
有關500錯誤的Apache錯誤日誌中的任何詳細信息? – megaflop
嘗試在'^/templates /(.*)/(.*)'中添加'$'使'^/templates /(.*)/(.*)$' – megaflop