问题:

开发人员启用了Magento 2的水印功能,但仍可从URL访问没有水印的原始产品图像。

例如:

缓存的带有水印的图片地址:

/pub/media/catalog/product/cache/df484df48ez74849c15sd4f7780/f/f/dsf-8f48d4f.jpg

没有水印的原始图片地址:

/pub/media/catalog/product/f/f/dsf-8f48d4f.jpg

因此,如果有人 从URL中删除/cache/df484df48ez74849c15sd4f7780/ 仍然可以访问无水印的原始照片来窃取图像。

开发者如何保护他的原始产品图像?

解决方案:

这里的简单解决方案是修改和使用以下/var/media/catalog目录中.htaccess文件:

Options +FollowSymLinks
RewriteEngine on

#The next coding line permits the original images to be accessed by admin end directly

RewriteCond %{HTTP_REFERER} !^http://www.yourwebsite.com/.*$ [NC]

#The next coding line permits the watermarked images to be accessed directly. It is according to the rule where the URL does not contain a cache.

RewriteCond %{REQUEST_URI} !(/cache/) [NC]

#It is the page where your store visitor will be redirected if they will attempt to access images directly.

RewriteRule \.(gif|jpg)$ http://en.wikipedia.org/wiki/You_shall_not_steal [R,L]

上述安全措施将帮助开发人员防止他的Magento产品图像被盗,下载和复制。

我们向您展示了一种简单的方法来保护Magento 2中的原始图像文件。如果您在遵循该指示时遇到任何问题,请联系我们