大网数据广告活动
网站运营与故障问答

How to 301 redirect old domain to new domain on same host with SSL and avoid Privacy Error

· 52CE 我爱测

Here's the environment: Apache, mod_rewrite.c exists WordPress Two domains that point to the same webhost, we'll call them www.olddomain.com www.newdomain.com We have an SSL Certificate for www.newdomain.com, but not www.olddomai…

问题原文

原帖链接 · Will Lanni · CC BY-SA 3.0

Here's the environment:

  • Apache, mod_rewrite.c exists
  • WordPress
  • Two domains that point to the same webhost, we'll call them
    • www.olddomain.com
    • www.newdomain.com

We have an SSL Certificate for www.newdomain.com, but not www.olddomain.com, as per the rules about needing two separate IPs for separate SSL certificates.

My current .htaccess file works great EXCEPT when you type in **https**://www.olddomain.com

Then the browser throws a Privacy Error "Your connection is not private" type page.

Here's what the .htaccess looks like:

Please note that the WordPress section and the Spam Referrer section probably have nothing to do with this, but I'm including them in case they're causing problems:

Options +FollowSymLinks -MultiViews
RewriteEngine on
#
# if requested hostname is non-blank
RewriteCond %{HTTP_HOST} .
# and if requested hostname is NOT "newdomain.com"
RewriteCond %{HTTP_HOST} !^www\.newdomain\.com
# redirect to same object in correct domain
RewriteRule (.*) https://www.newdomain.com/$1 [R=301,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

##Block Spam Referrer
SetEnvIfNoCase Referer blackhatworth.com spam=yes
SetEnvIfNoCase Referer priceg.com spam=yes
Order Allow,Deny
Allow from all
Deny from env=spam

已采纳解答

原帖链接 · dartonw · CC BY-SA 3.0

While it isn't impossible to host multiple secure sites on a single IP address, thanks to SNI and SAN, the redirect you're trying to do is impossible without one of the aforementioned solutions. In order to receive a redirect from https://www.olddomain.com, the browser must have already requested that URL using SSL/TLS, and is expecting an encrypted response from the web server with a valid certificate for that domain - even if that response is only a 301.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2015-04-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。