2011-11-17 64 views
0

這是很好的磁提供圖片的水印所以水印圖像將顯示爲保護Magento的圖像

http://www.yourwebsite.com/media/catalog/product/cache/1/image/de684549e4151748e56ee0dd7902c19f/m/y/my-first-image.jpg 

這是一件好事。但是,如果有人刪除緩存/ 1 /圖片/ de684549e4151748e56ee0dd7902c19f URL的一部分,使之成爲

http://www.yourwebsite.com/media/catalog/product/m/y/my-first-image.jpg 

他可以查看圖像,並將其複製。解決這個問題的最好方法是什麼?

回答

0

那麼,創建自己的圖像與水印!就像如果刪除緩存,緩存會從已經水印圖像

0

重建圖像您可以在其中創建媒體/目錄文件夾的.htaccess文件有以下幾行:

Options +FollowSymLinks 
RewriteEngine on 

RewriteRule ^(.*?/cache.*)$ $1 [L] 
RewriteRule ^(.*)$ $1 [F] 

如果用戶嘗試查看原始文件,但是讓他們看到緩存中的圖像,則會向用戶返回403。

這會中斷預覽管理中的圖像,因爲它們顯示的是原始文件而不是生成的縮略圖。

+0

謝謝Jasuten!我可以通過下面的答案發布一些細微的修改。 – Farrukh

1

這就是我設法做到的。

在它把一個.htaccess文件中media/catalog/夾在Magento與下面的代碼

Options +FollowSymLinks 
RewriteEngine on 
#Following line allows the actual images to be accessed by admin end directly 
RewriteCond %{HTTP_REFERER} !^http://www.yourwebsite.com/.*$ [NC] 
#Following line allows the watermarked images to be accessed directly. Rule says that if URL does not contain cache 
RewriteCond %{REQUEST_URI} !(/cache/) [NC] 
#This is the page where visitor will be redirected if tries to access images directly. 
RewriteRule \.(gif|jpg)$ http://www.yourwebsite.com/do-not-try-to-steal-images.html/ [R,L]