实际上,我关心的是重定向内部和外部 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时,它要求我添加异常并重定向到没有加密的页面。
请帮忙!