Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
Php Https重定向问题_Php_.htaccess_Https - Fatal编程技术网

Php Https重定向问题

Php Https重定向问题,php,.htaccess,https,Php,.htaccess,Https,我在Flexible(免费)上使用Cloudflare的SSL,它工作得非常好。 我已经设置了从https://到//的所有文件和链接,使它们可以通过https工作 我还在我的.htaccess文件中设置了以下内容,以使任何客户端自动从http转到https: RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$ RewriteRule ^(.*)$ - [env=askapache:%2] .htaccess代码的问题在于,它只将我的站点的根索引文件(

我在Flexible(免费)上使用Cloudflare的SSL,它工作得非常好。 我已经设置了从
https://
//
的所有文件和链接,使它们可以通过https工作

我还在我的
.htaccess
文件中设置了以下内容,以使任何客户端自动从http转到https:

RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
RewriteRule ^(.*)$ - [env=askapache:%2]
.htaccess
代码的问题在于,它只将我的站点的根索引文件(例如,
http://example.com/index.php
将重定向到
https
http://example.com/folder/index.php
不会


我的第二个问题是,即使我做了一个简单的
href=”https://example.com/folder/index.php“
href=“//example.com/folder/index.php”
它只会将我带到基本的http url。

如果您使用的是CloudFlare,您可以在页面规则中定义始终使用SSL


对于.htaccess(递归):


为什么不使用?所有答案都有效,可以从http重定向到https,但我得到一个重定向循环,不允许加载页面。检查apache ssl conf是否正确设置;)我将与我的主机提供商进行实时聊天,看看他们是否有帮助。他们无法帮助:/I我如何定义通过页面规则始终使用SSL?@YuukiAsuna:请参阅的帮助。为循环:非常疯狂。服务器日志是怎么说的?
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]