限制 Web 服务 IIS6/7 对文件夹内文件的访问
我正在寻找一种方法来限制对我们网站上某个或多个文件夹的直接访问,该文件夹在我们的第二个开发环境中托管在 IIS7 中,在第一个开发环境中托管在 IIS6 中,在生产中托管在 IIS6 中。
基本上我们应该能够从我们的网站链接到这些文件,即: http://www.domain.com/stuff/survey.pdf
但是如果有人尝试从博客文章等链接到此内容。它不应该提供内容。有没有办法在 Web 配置中做到这一点,或者这超出了 IIS 的能力?
I am looking for a way to restrict direct access to a certain folder or folders on our website which is hosted in IIS7 in our second dev environment, IIS6 in our first dev environment and IIS6 on production.
Basically we should be able to link to these files from our website i.e.:
http://www.domain.com/stuff/survey.pdf
But if someone tries to link to this from a blog post, etc. it should not serve the content. Is there any way to do this in a web config or is that beyond the abilities of IIS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终做的是编写一个 PHP 脚本,该脚本提供来自 Web 根目录外部的内容,但前提是用户已登录并拥有有效的站点 cookie。
然后我创建了文件夹来替换我们当前提供的所有内容(.pdf、.png 等),因为我们想要保护的内容并不多。我将该文件夹命名为与原始文档相同的名称,即:/webroot/survey.pdf/,然后将index.php 放入survey.pdf 文件夹中。
这很有效,现在我们可以使用脚本链接到我们想要保护的内容。
What I ended up doing was writing a PHP script which served content from outside of the web root, but only if the user was logged in and had a valid site cookie.
Then I created folders to replace all the content we were currently serving (.pdf, .png, etc.) since there was not that much that we wanted secured. I name the folder the same as the original document, i.e.: /webroot/survey.pdf/ and then placed the index.php inside of the survey.pdf folder.
This worked, and now we can use the script to link to content that we want secured.