MAK*_*MAK 7 ssl https http cpanel ssl-certificate
将网站网址http重定向到https..for我在我的cpanl public_html根目录中上传.htaccess文件.该文件的代码为
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://sitename.in/$1 [R,L]
Run Code Online (Sandbox Code Playgroud)
在我托管此文件后,它也没有将我的网站重定向到https协议
Shi*_*ngh 16
我写这个答案太晚了,但目前工作正常.因此,请尝试在根目录.htaccess文件中执行此操作.
# Force SSL
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
注意:只有mod_rewrite在cpanel服务器上安装它才会起作用,否则使用php base SSL redirect.
我在网站的索引页中添加了以下几行代码
if($_SERVER["HTTPS"] != "on")
{
header("Location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
exit();
}
Run Code Online (Sandbox Code Playgroud)
然后网站url重定向到https链接
| 归档时间: |
|
| 查看次数: |
28366 次 |
| 最近记录: |