【发布时间】:2020-08-07 16:59:20
【问题描述】:
当我输入网址时,它会重定向到http://www.xyz.in,但如果我将其编辑为https://www.xyz.in,SSL 证书就会开始工作。
问题是当用户输入xyz.in时如何重定向到https://www.xyz.in
配置文件:
$root = (isset($_SERVER['HTTPS']) ? "https://" : "http://") . $_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;
.htaccess 文件:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} (www\.)?xyx.in
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
我尝试将RewriteCond %{HTTPS} off 更改为on,但它总是重定向到http://xyz.in。
【问题讨论】:
-
这能回答你的问题吗? How to redirect all HTTP requests to HTTPS
标签: php apache .htaccess codeigniter redirect