阻止从 Magento 中的媒体文件夹下载
如果有人知道服务器上媒体文件的文件夹路径,是否有任何新方法可以阻止他们直接下载媒体文件? 我知道以前从来没有,但想知道在过去的几年里是否出现了任何新的东西?
或者也许我之前错过了一些东西,而这总是可能的?
我的 Magento 1.4.0.1 商店有大量图像,其中很多是我投入了大量工作的。我正在使用 Magento 水印系统,该系统工作正常,但如果您知道图像的直接文件系统路径,您将获得原始的无水印图像。
如果可以的话我想阻止它?
干杯!
Are there any new methods to prevent someone directly downloading a media file if they know the folder path to it on the server?
I know there never used to be, but wondered if anything new to this end had cropped up in the last couple of years?
Or maybe I missed something before and this was always possible??
My Magento 1.4.0.1 store has tons of images, a lot of which I have put a lot of woork into. I am using the Magento watermarking system, which works fine, but if you know the direct file system path to the image, you get served the original, non-watermarked image.
I'd like to stop that if possible?
Cheers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决方案是通过
.htaccess
拒绝访问这些文件夹。 PHP 留给我们的坏习惯之一是将所有内容都放在 Web 根目录中,正如您所说,这允许人们在网站本身的上下文之外访问单个文件。但是,您可以将一个名为.htaccess
的文件放置在任何您喜欢的文件夹中以阻止该访问。文件的内容应如下所示:请注意,这仍将允许 PHP 访问文件以生成新的拇指,但将禁止所有浏览器访问这些文件。
希望有帮助!
谢谢,
乔
The solution to this is to deny access to those folders via
.htaccess
. One of the bad habits that PHP leaves us with is putting everything inside of the web root, which as you say allows people to access individual files out of context of the website itself. However, you can place a file in any folder you like called.htaccess
to block that access. The contents of the file should look something like this:Note that this will still allow PHP to access the files to generate new thumbs, but will disallow all browser access to the files.
Hope that helps!
Thanks,
Joe
预先给图像加水印对您来说是一个可以接受的解决方案吗?您还将在此过程中节省一些周期。简单的Google 搜索就可以找到一些免费(如啤酒)水印工具的链接。不过,我还没有测试过其中任何一个。
Would watermarking your images beforehand be an acceptable solution for you? You'll also save some cycles in the process. A simple Google search turned up some links to free (as in beer) watermarking tools. I haven't tested any of those, though.