【问题标题】:read Hypertext Transfer Protocol (HTTP or HTTPS)阅读超文本传输​​协议(HTTP 或 HTTPS)
【发布时间】:2011-06-07 06:58:52
【问题描述】:

我想读取用户使用的协议。 HTTP 或 HTTPS 并相应地在该页面上为站点 2 构建我的 url。

第 1 步:Read the url user is on site 1 //可以是任何 http 或 https

第二步:Prefix the protocol for site 2 on that site 1 page according. HTTP or HTTPS as per step 1

FF 处理得很好。但是 IE 不允许从 HTTPS 站点导航到 HTTP 站点。

   <a href="protocol://site2.com/">Click here for site 2</a>

【问题讨论】:

  • 不允许是什么意思?你的实际问题是什么?

标签: http url https


【解决方案1】:

通过我的 jsp,我能够将 URL 分成几部分。例如,https://test.com:8080/ 会产生:

request.getScheme() = https
request.getServerName() = test.com
request.getServerPort() = 443

详情请见this document

【讨论】:

    【解决方案2】:

    你想用什么语言来做?

    对于 JavaScript,有 parent.location.protocol

    对于 PHP,您可以尝试使用 $_SERVER['SERVER_PORT'] == 443 甚至 $_SERVER['HTTPS']

    【讨论】:

    • 您可以尝试使用HttpServletRequest.getProtocol()HttpServletRequest.isSecure()
    【解决方案3】:

    我在我的 JSP 中使用 String scheme = request.getScheme(); 做到了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-25
      • 2013-03-03
      • 2013-01-16
      • 2020-04-16
      • 1970-01-01
      相关资源
      最近更新 更多