【问题标题】:Detecting https in htaccess - all possibilites在 htaccess 中检测 https - 所有可能性
【发布时间】:2018-05-15 14:18:56
【问题描述】:
RewriteRule .* - [E=protocol:http]

RewriteCond %{ENV:HTTPS} ^on$ [NC,OR]
RewriteCond %{ENV:REQUEST_SCHEME} ^https$ [NC,OR]
RewriteCond %{HTTPS} ^on$ [NC,OR]
RewriteCond %{REQUEST_SCHEME} ^https$ [NC,OR]
RewriteCond %{HTTP:X-Forwarded-Proto} ^https$ [NC]
    RewriteRule .* - [E=protocol:https]

上面的代码怎么可能不起作用?此代码以各种可能的方式逐字检查是 http 还是 https 将其存储到 var。

但最后protocol var 始终具有http 值。不管你输入http://example.com还是https://example.com

【问题讨论】:

  • 这对我有用。

标签: .htaccess http https


【解决方案1】:

唯一对我有用的是:

RewriteCond %{SERVER_PORT} ^443$

很奇怪,最流行的方法都行不通。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-08
    • 2016-08-07
    • 2015-01-09
    • 1970-01-01
    • 1970-01-01
    • 2011-01-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多