1

实际上,我关心的是重定向内部和外部 IP 地址到域名和任何http://domain流量到https://domain,我通过在 httpd.conf 文件中添加这些行来实现:

#Redirect IP to domain name

<IfModule rewrite_module>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^172\.1\.20\.4$ [NC,OR]
RewriteCond %{HTTP_HOST} ^83\.101\.140\.185$ [NC]
RewriteRule (.*) http://ict-helpdesk.madanonwovens.com/$1 [R=301,L]
</IfModule>

#Redirect all connections to HTTPS

<IfModule rewrite_module> 
RewriteEngine On 
#Force SSL on all connections 
RewriteCond %{HTTPS} off 
RewriteCond %{REMOTE_HOST} !^127\.0\.0\.1 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 
</IfModule>

但是现在我想将https://IP-address重定向到https://domain 因为当我写https://IP-address时,它要求我添加异常并重定向到没有加密的页面。

请帮忙!

4

1 回答 1

-1

Atlast,我通过在应用程序根目录中生成 .htaccess 文件来实现这一点,并在文件中添加了相同的规则,但它仍然要求在浏览器中添加异常,然后重写条件通过 IP 地址重写域名。

当用户键入https://IP-address而不在浏览器中添加异常时,有什么方法可以自动重定向到域名。

于 2017-11-21T11:54:51.067 回答