如何将example.com从HTTPSredirect到HTTP,然后将HTTP example.comredirect到newdomain.com?

截至目前,我使用此规则(在example.com的.htaccess中)将HTTPS / HTTP example.comredirect到newdomain.com:

Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://newdomain.com/$1 [R=301,L] 

从search中,我发现以下规则将HTTPSredirect到HTTP:

 RewriteEngine On RewriteCond %{HTTPS} on RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} 

如何合并这些,以便 – https://example.comredirect到http://example.com ,然后http://example.comredirect到http://newdomain.com

我无法解释为什么我不要求这样的事情 – HTTPS /redirect到http://newdomain.com 。 总之,我已经search和问,并build议的规则不起作用,可能因为我使用自签名的证书,并为这两个域相同的证书(example.com是一个插件域,newdomain.com是主要的领域)。 请指教,如果这是有道理的。

有趣的要求,我不知道我明白你为什么要这样做 – 它只是使两个301响应去newdomain.com而不是一个..但是,我想这将做到这一点:

 RewriteEngine on # First rule - if this is an SSL connection, then redirect # to http://example.com then stop processing other rules RewriteCond %{HTTPS} on RewriteRule (.*) http://example.com/$1 [R=301,L] # Second rule - all other requests, redirect to http://newdomain.com. RewriteRule (.*) http://newdomain.com/$1 [R=301,L] 

感谢所有的帮助@Shane Madden。 得到这一切工作。 这是我正在使用的.htaccess(example.com)规则:

 Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^.*example\.com$ [NC] RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L] 

之前没有工作的原因是因为这两个域使用相同的SSL证书(因为一个是另一个域的Cpanel帐户下的插件域)。 “HTTPSredirect不适用于插件域”。

所以,我所做的是为example.com创build一个新的cpanel帐户。 也就是说,为example.com获得单独的SSL证书就像这样简单。