Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.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使用https将php重定向到html_Php_Html_.htaccess_Redirect_Ssl - Fatal编程技术网

htaccess使用https将php重定向到html

htaccess使用https将php重定向到html,php,html,.htaccess,redirect,ssl,Php,Html,.htaccess,Redirect,Ssl,我对激活SSL的htacces重写规则有问题 在htacces中,我将所有地址.php重定向到.html: RewriteBase / RewriteCond %{THE_REQUEST} (.*)\.php RewriteRule ^(.*)\.php $1.html [R=301,L] RewriteCond %{THE_REQUEST} (.*)\.html RewriteRule ^(.*)\.html $1.php [L] 如果我通过以下方式将ssl重定向添加到https

我对激活SSL的htacces重写规则有问题

在htacces中,我将所有地址
.php
重定向到
.html

RewriteBase /
RewriteCond %{THE_REQUEST} (.*)\.php  
RewriteRule ^(.*)\.php $1.html [R=301,L]  
RewriteCond %{THE_REQUEST} (.*)\.html  
RewriteRule ^(.*)\.html $1.php [L]
如果我通过以下方式将ssl重定向添加到https:

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 
将php重写为html不起作用

例如:

http://domain.com/test.html——工作

http://domain.com/test.php-->已重定向到HTML并开始工作

https://domain.com/test.php-->未重定向--工作

https://domain.com/test.html-->错误404-找不到页面

已解决 https站点的apache2配置中存在问题:

将AllowOverride None更改为AllowOverride All

尝试以下操作:

RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteCond %{THE_REQUEST} (.*)\.php  
RewriteRule ^(.*)\.php https://%{HTTP_HOST}/$1.html [R=301,L]

RewriteCond %{HTTPS} !=on
RewriteCond %{THE_REQUEST} (.*)\.html  
RewriteRule ^(.*)\.html https://%{HTTP_HOST}/$1.php [L]

你的规则是这样的:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]

RewriteCond %{THE_REQUEST} \.php [NC]
RewriteRule ^(.+?)\.php$ $1.html [R=301,L]  

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?)\.html $1.php [L]

谢谢你的帮助。。问题已解决->原始Topik中的解决方案谢谢您的帮助。。问题已解决->原始TOPIK中的解决方案很高兴知道,您可以通过单击我答案左上角的勾号将答案标记为已接受。