我必须将我的网站从https://www.example.com/
to https://website.com/
.
SSL已正确安装在我的服务器上。
我在用Apache并且必须使用来做到这一点Apache(任何一个httpd.conf/ssl.conf
or .htaccess
)
我几乎使用了所有我能搜索到的方法,但没有一个对我有用。
But
-
https://www.example.com/
不重定向正确地https://example.com/
.
它给我“无效的证书错误”,当我在浏览器中添加异常(接受证书)时,它会重定向到https://example.com/
。但我不想添加这个例外(在浏览器中添加证书)。
请注意,我的 SSL 证书是为example.com
并不是www.example.com
.
以下是我的.htaccess
规则和条件
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L]
我也使用过以下内容,但这些也不起作用:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^example.com$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]
也用过这个,但没有运气
RewriteEngine On
RewriteCond %{HTTP_HOST} !^example.com$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]
这也没有运气
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
我尝试了 5-6 个其他解决方案(与上面类似),但没有一个有效。所有这些都适用于我上面提到的前两种模式,但没有一个适用于https://www
.
请注意,这些条件.htaccess
达到了,我的意思是.htaccess
并没有被忽视。我已经使用重定向验证了这一点,并且上面提到的两种模式也有效。
In httpd.conf/ssl.conf
the AllowOverride
指令设置为All
.
我可以访问httpd.conf/ssl.conf
.
PHP版本 5.5.29
Apache2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.5.29
主机名:端口example.com:443
最后但并非最不重要的一点是我的网站https://example.com/
无法在 Internet Explorer 和 Safari 中打开并给出证书问题(错误),但是当我使用 SSL 检查器(多个)检查我的域时,所有 SSL 检查器都会提到 SSL 已正确安装。
检查这张图片,这会更好地解释事情:
完全的.htaccess
如下:
Options +FollowSymlinks
DirectoryIndex index.html Home.php index.php
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^.*$ https://%1/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://{REQUEST_URI} [L,R=301]
RewriteRule ^(blogs)($|/) - [L]
RewriteRule ^(.*)/$ index.php?mod=resturants&name=$1&%{QUERY_STRING} [L]
RewriteRule ^$ Home.php [L]
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
</IfModule>