.htaccess将IP地址重定向到HTTPS域

时间:2015-10-12 03:27:52

标签: php apache .htaccess redirect

我正在尝试将我的网站IP地址重定向到其https域,但我收到错误

Your connection is not private

Attackers might be trying to steal your information from 123.123.123.123 
(for example, passwords, messages, or credit cards). NET::ERR_CERT_COMMON_NAME_INVALID

这是我当前的.htaccess文件

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^123\.123\.123\.123
RewriteRule (.*) https://example.com/$1 [R=301,L]

1 个答案:

答案 0 :(得分:0)

string startime = record.TimeStart; string endtime = record.TimeFinish; TimeSpan span = DateTime.Parse(endtime).Subtract(DateTime.Parse(startime)); string hours_spent = string.Format( "{0:D2}:{1:D2}:{2:D2}", span.Hours, span.Minutes, span.Seconds); 是您必须为自己的域名购买的证书。所以它会保护您的网站。

除了谷歌以外,还有很多关于Force Redirect http to https.的答案 但它根本不起作用。因为你不能强制重定向。它会使用 https警告加载您的网站。

  

因此最好购买SSL Certificate

强制重定向Malitious

.htaccess

或允许IP

RewriteEngine On 
RewriteCond %{HTTP_HOST}^example\.com [NC]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]