Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.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 网站不知何故丢失了“;强制删除www";_.htaccess_Ssl_Url Rewriting - Fatal编程技术网

.htaccess 网站不知何故丢失了“;强制删除www";

.htaccess 网站不知何故丢失了“;强制删除www";,.htaccess,ssl,url-rewriting,.htaccess,Ssl,Url Rewriting,我的网站曾经有“强制SSL”和“强制删除www”。但现在它失去了“力量”。更清楚地说,现在是“强制www” my.htaccess中的相关代码是 RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] RewriteCond %{HTTPS} off RewriteRule ^ ht

我的网站曾经有“强制SSL”和“强制删除www”。但现在它失去了“力量”。更清楚地说,现在是“强制www”

my.htaccess中的相关代码是

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
我根本没有更改上面的代码。我已经联系了我的网络托管公司,他们说问题出在.htaccess中

如果我必须指出一个可能的原因,那可能是(我的网络托管公司)的一名支持人员帮助我更改了PHP版本。这可能就是为什么在my.htaccess的开头添加了两行代码:

# Use PHP56 Single php.ini as default
AddHandler application/x-httpd-php56s .php

但我不确定这是否真的是原因。

您的代码添加了www.Use:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

谢谢您!现在所有页面都正常工作。我真的不知道为什么旧代码突然停止工作。我根本没有改变它们。无论如何,谢谢你!