在 Http 或 Https 之间切换(基于父目录)
我有一个会员区目录。
该目录中的所有文件都应通过 https 处理。
特定目录之外的所有其他文件应由 http 处理。
如何自动从 http 和 https 进行重定向,反之亦然?
顺便说一句,链接是相对的。
I have a direcory for the members area.
All the files within that directory should be treated by https.
All other files outside the specific dir should be treated by http.
How can i automate the redirecting from http and https and vice versa?
Btw, the links are relative.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 在 HTTP 和 HTTPS 之间自动切换中的 SecureWebPages 程序集和 web.config 条目:版本 2。 这是一个很好的工具包,我过去用它来自动将登录和管理页面切换到 https
You can use the SecureWebPages assembly and web.config entries from Switching Between HTTP and HTTPS Automatically: Version 2. It's a nice piece of kit, I've used it in the past to automatically switch login and admin pages to https
我能想到的覆盖人类的最好的办法就是使用 javascript 重写 url。 如果它们都是相对的,那么就不应该太棘手。
我注意到,像这样的混合网站有一些缺点,主要是浏览器不喜欢涉及不安全 HTTP 请求的 HTTPS 页面。 更好的计划可能是让一切都是相对的,只有在需要点击 https 部分时才切换到 https 模式。
我可以看到使用 IIS 执行此操作的几种方法,但这些选项实际上取决于您可以对 IIS 配置进行多少操作以及您拥有哪些类型的资源。
Best thing I can think of to cover humans would be to rewrite the urls using javascript. If they are all relative then it shouldn't be too tricky.
I'd note that mixing sites like this have some drawbacks, principally browsers don't like HTTPS pages with insecure HTTP requests involved. A better plan might be to make everything relative and only kick over to https mode once you need to hit the https section.
I can see a few ways to do this using IIS, but those options really depend on how much you can muck with the IIS configuration and what sorts of resources you have.
这听起来最好通过 HTTP 服务器配置来管理。 例如 mod_rewrite 和类似的。
尝试在 https://serverfault.com/ 上询问
This sounds like it might best be managed through HTTP server configuration. E.g. mod_rewrite and similar.
Try asking on https://serverfault.com/