使用特定域的.htaccess重定向到HTTPS [英] Redirect to HTTPS with .htaccess with a specific domain

查看:90
本文介绍了使用特定域的.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆