我尝试寻找与我的问题相关的帖子,但找不到合适的帖子。如果有,请告诉我!
这是我现在面临的现状。我想重定向一个域,
example.hr
正在与另一台服务器一起使用,并且它附带了一个 SSL。
现在,我有另一台服务器自带的域,
example.co
还有 SSL 证书。
我想将 test.example.hr 重定向到 https://example.co .我该怎么做呢?我正在使用子域对其进行测试,因为根域已被使用。
这个方法我试过了,
<VirtualHost *:80>
ServerName test.example.hr
ServerAlias www.test.example.hr
Redirect / https://example.co/
</VirtualHost>
<VirtualHost *:443>
ServerName example.co
ServerAlias www.example.co
DocumentRoot /var/www/html
ErrorLog /var/www/html/error.log
CustomLog /var/www/html/access.log combined
</VirtualHost>
SSL 配置在 443 block 内。
当我转到 test.example.hr 时,它将变为 https://test.example.hr并且出现的错误是“您的连接不是私密的。攻击者可能试图从 test.alt.hr 窃取您的信息(例如,密码、消息或信用卡)。了解更多 NET::ERR_CERT_COMMON_NAME_INVALID"
最佳答案
你能试试这个并更新我吗。
<VirtualHost *:80>
ServerName test.example.hr
ServerAlias www.test.example.hr
Redirect / http://example.co/
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>
<VirtualHost *:443>
ServerName example.co
ServerAlias www.example.co
DocumentRoot /var/www/html
ErrorLog /var/www/html/error.log
CustomLog /var/www/html/access.log combined
</VirtualHost>
确保启用a2enmod rewrite
关于apache - 将子域 A 重定向到 https 域 B,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49425279/