htaccess的二级域名重定向到使用SSL主域 [英] .htaccess redirect secondary domain to primary domain with SSL

查看:146
本文介绍了htaccess的二级域名重定向到使用SSL主域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的二级域名重定向到我的.COM的主域,当我访问domain.asia或者使得www.domain.asia重定向的URL的 https://www.domain.com 。我遇到的问题是,重定向进入 https://www.domain.asia (不是.COM )及.ASIA域不具有安全证书并且因为这种显示一个警告。

我如何可以访问domain.asia并将它重定向到 https://www.domain.com

二级域名停放在同一台服务器作为主域上。这是我的.htaccess文件:

 #重定向到.COM
的RewriteCond%{HTTP_HOST} ^(WWW \)?域\ .CO \ .UK $ [NC]
的RewriteCond%{HTTP_HOST} ^(WWW \)?域\ .ASIA $ [NC]
重写规则^(。*)$ https://www.domain.com/$1 [R = 301,L]

#重定向到www
的RewriteCond%{HTTP_HOST}!^ WWW \。
(。*)重写规则^ $ HTTP://www.% {HTTP_HOST} / $ 1 [R = 301,L]

#重定向到https,如果不
的RewriteCond%{} HTTPS!=上
的RewriteCond%{HTTP_HOST} ^(WWW \)?域\ .COM $ [NC]
重写规则^ https://开头%{HTTP_HOST}%{REQUEST_URI} [R = 301,L]
 

解决方案

您必须使用:

 #重定向到.COM
的RewriteCond%{HTTP_HOST} ^(WWW \)?域\ .CO \ .UK $ [OR,NC]
的RewriteCond%{HTTP_HOST} ^(WWW \)?域\ .ASIA $ [NC]
重写规则^(。*)$ https://www.domain.com/$1 [R = 301,L]
 

,使用此规则条件结合本地或代替隐式和。

I am wanting to redirect my secondary domain to my .com primary domain, such that when I visit domain.asia or www.domain.asia it redirects the URL to https://www.domain.com. The problem I am having is that the redirect goes to https://www.domain.asia (not the .com) and the .asia domain does not have a security certificate and because of this shows a warning.

How can I visit domain.asia and have it redirected to https://www.domain.com?

The secondary domain is parked on the same server as the primary domain. Here is my .htaccess file:

# redirect to .com
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.co\.uk$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.asia$ [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]

# redirect to www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# redirect to https if not
RewriteCond %{HTTPS} !=on
rewritecond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

解决方案

You have to use:

# redirect to .com
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.co\.uk$ [OR,NC]
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.asia$ [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]

with OR, Use this to combine rule conditions with a local OR instead of the implicit AND.

这篇关于htaccess的二级域名重定向到使用SSL主域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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