2014-10-18 97 views
0

我的託管圖片已鏈接到其他網站,所以現在我想將這些鏈接重定向到我的網站。 我的圖片鏈接看起來像這樣 http://example.com/uploads/images/September2014//iphone-6.gif(所有圖像類型JPG,GIF,PNG等) sepetember2014/是每個月都會變化的動態文本(MONTHNAME(字母)年(位)),加上額外/上其結束。 現在我想上面的URL重定向到將其他網站的所有圖片鏈接重定向到網址

http://example.com/media/iphone-6 

我嘗試以下,但didint工作

RewriteCond %{HTTP_REFERER} !example.com 
RewriteRule ^\.jpg $1\.html [R=301,L 

我的網站htacess這個樣子 使用anubhava答案

RewriteRule ^$ public/ [L] 
RewriteRule (.*) public/$1 [L] 

RewriteCond %{HTTP_REFERER} !example\.com$ 
RewriteRule ^uploads/images/.+?/([^./]+)\.jpg$ /media/$1 [R=301,L,NC] 
+0

什麼是您的服務器'example.com'或'yourdomain.com'? – anubhava 2014-10-18 18:40:13

+0

我修復了它的example.com – Dexture 2014-10-18 18:42:49

回答

1

你的正則表達式沒有按」後t似乎是正確的。您可以使用此規則爲第一條規則在你的根的.htaccess:

RewriteCond %{HTTP_REFERER} !example\.com$ 
RewriteRule ^uploads/images/.+?/([^./]+)\.jpg$ /media/$1.html [R=301,L,NC] 
+0

它完全重定向,但隨後我的圖像根本不顯示在我的網站上 – Dexture 2014-10-18 19:20:29

+0

即使您刪除了此規則,並且在您的http:// example.com/media/iphone-6中輸入了瀏覽器是否找到你的圖片? – anubhava 2014-10-19 05:01:03

+0

是刪除新規則後http://example.com/me dia/iphone-6顯示圖片 – Dexture 2014-10-19 06:27:59

相關問題