Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 检测htaccess中的https-所有可能性_.htaccess_Http_Https - Fatal编程技术网

.htaccess 检测htaccess中的https-所有可能性

.htaccess 检测htaccess中的https-所有可能性,.htaccess,http,https,.htaccess,Http,Https,上面的代码怎么可能不工作?这段代码以各种可能的方式逐字检查是否是http或https,以将其存储到var 但是在最后,protocolvar总是http值。如果键入http://example.com或https://example.com唯一适合我的是: RewriteRule .* - [E=protocol:http] RewriteCond %{ENV:HTTPS} ^on$ [NC,OR] RewriteCond %{ENV:REQUEST_SCHEME} ^https$ [NC,O

上面的代码怎么可能不工作?这段代码以各种可能的方式逐字检查是否是http或https,以将其存储到var


但是在最后,
protocol
var总是
http
值。如果键入
http://example.com
https://example.com

唯一适合我的是:

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]

太奇怪了,大多数流行的方法都不起作用。

这对我来说是可行的。
RewriteCond %{SERVER_PORT} ^443$