ASP.NET HTTPS 和相对 URL
我有一个带有 www.foo.com SSL 证书的网站。 将请求重定向到 https:// 前缀的最简洁方法是什么? 我是否必须在服务器端构建链接,而不是依赖于相对路径 ~/ 解析 url?
另外,假设我重定向到 https:// 页面,页面上的链接都是在母版页中创建的,并使用相对路径解析。 如果用户单击任何导航元素,他们基本上会卡在 https:// 路径上,那么清理该路径的最佳方法是什么?
这些路径都需要在开发(本地主机)、登台和生产环境中工作。
I have a site with an SSL cert for www.foo.com. What is the cleanest way redirect requests to the https:// prefix? Do I have to build links server side instead of relying on resolving urls with relative paths, ~/?
Also, say I redirect to an https:// page, the links on the page are all created in a master page and are resolved with relative paths. If the user clicks on any of the navigation elements they are essentially stuck on the https:// path, what is the best way to clean that up?
The paths all need to work in the dev (localhost), staging, and production environments.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以设置
You can set the <base> tag in your html, which would mean everything would then be relative to that base url.
不,您不需要做任何事情,
除非您发出完全限定的网址,否则您的每个相对网址重定向和路径始终与 https:// 一起考虑,例如,
您的页面网址是 https://mysite/folder1/page.aspx 并且如果您发出 Response.Redirect("/folder2/page2.aspx") 那么仅 Web 服务器问题相对网址“/folder2/page2.aspx”,但客户端(IE/FF2/Safari)附加“https://mysite” 位于网址之前。
所以只要你在项目中使用相对url,你就是安全的。
No you dont need to do anything,
Unless you issue a fully qualified url, your every relative url redirects and paths are always considered along with https:// for example,
Your url of page is https://mysite/folder1/page.aspx and if you issue Response.Redirect("/folder2/page2.aspx") then web server only issues relative url "/folder2/page2.aspx" but the client (IE/FF2/Safari) they append "https://mysite" before the url.
So as long as you use relative urls in your project, you are safe.