Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.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使用http和https重定向_.htaccess_Http_Https - Fatal编程技术网

.htaccess使用http和https重定向

.htaccess使用http和https重定向,.htaccess,http,https,.htaccess,Http,Https,我需要从http/site.ru重定向到http/www.site/com和 在一个htaccess文件中从https/site.ru到https/www.site.com RewriteEngine On RewriteCond %{HTTP_HOST} ^site\.ru$ [NC,OR] RewriteCond %{HTTP_HOST} ^www.site\.ru$ [NC,OR] RewriteCond %{HTTP_HOST} ^site\.com$ [NC] RewriteCond

我需要从http/site.ru重定向到http/www.site/com和 在一个htaccess文件中从https/site.ru到https/www.site.com

RewriteEngine On

RewriteCond %{HTTP_HOST} ^site\.ru$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.site\.ru$ [NC,OR]
RewriteCond %{HTTP_HOST} ^site\.com$ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ http://www.site.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^site\.ru$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.site\.ru$ [NC,OR]
RewriteCond %{HTTP_HOST} ^site\.com$ [NC]
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ https://www.site.com/$1 [R=301,L]

问题是什么条件总是将我从https重定向到http。如果是http和https,我需要保存http。如果是https,我需要保存http。

使用服务器变量
server\u PROTOCOL
作为协议。你能写更多关于它的内容吗?谢谢,但我读了又读,不明白发生了什么。