簡體   English   中英

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

[英].htaccess Redirect IP address to HTTPS domain

我試圖將我的網站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]

https是您必須為您的域名購買的證書。 所以它將保護您的網站。

除了在谷歌有很多關於強制重定向httphttps的答案 但它根本不起作用。 因為你不能強制重定向。 它將使用Malitious警告加載您的站點。

所以最好購買SSL證書

強制重定向.htaccess

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

或者允許IP

   #Allow List

    order allow,deny
    allow from 123.123.123.123 #specify a specific address
    allow from 123.123.123.123/30 #specify a subnet range
    allow from 123.123.* #specify an IP address wildcard
    deny from all

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM