使用具有特定域的 .htaccess 重定向到 HTTPS [英] Redirect to HTTPS with .htaccess with a specific domain
本文介绍了使用具有特定域的 .htaccess 重定向到 HTTPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前有 2 个域可以访问我服务器上的同一个文件夹:metrikstudios.com 和 ziced.com.
I currently have 2 domains that access to the same folder on my server: metrikstudios.com and ziced.com.
我希望通过 http://metrikstudios.com 进入的用户被重定向到 https://metrikstudios.com 以及通过 http://ziced.com 不要重定向到 https://ziced.com.
I want the users that enter through http://metrikstudios.com be redirected to https://metrikstudios.com and the users that enter through http://ziced.com don't be redirected to https://ziced.com.
我目前在我的 .htaccess 上有这个
I currently have this on my .htaccess
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
谢谢
推荐答案
你可以简单地添加另一个 RewriteCond 来检查主机是否是metrikstudios.com
You could simply add another RewriteCond to check if the host is metrikstudios.com
RewriteCond %{HTTP_HOST} ^metrikstudios.com [NC]
它应该是这样的:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^metrikstudios.com [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
这篇关于使用具有特定域的 .htaccess 重定向到 HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文