You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用.htaccess重定向子域名至外部站点时HTTPS功能异常的问题求助

使用.htaccess重定向子域名至外部站点时HTTPS功能异常的问题求助

各位技术大佬们,我最近碰到个棘手的问题:我打算通过.htaccess把help.example.com这个子域名重定向到一个外部站点,但现在HTTPS功能完全不正常——要么访问时自动跳转到不安全的HTTP,要么浏览器弹出证书无效的警告。

我先把当前的Apache虚拟主机配置贴出来,麻烦大家帮忙排查下问题所在:

<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin ouremail@email.com
DirectoryIndex index.php
DocumentRoot /var/www/html/
ServerName ub-web-prod01.example.com
ServerAlias example.com www.example.com

<Directory /var/www/html/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>

<VirtualHost *:443>
ServerAdmin ouremail@mail.com
DirectoryIndex index.php
DocumentRoot /var/www/html/
ServerName help.example.com

<Directory /var/www/html/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combin...

目前我尝试过调整.htaccess里的重定向规则,但不管是用RewriteRule还是Redirect,HTTPS的问题都没法解决。有没有大佬能指点下,是不是我的虚拟主机配置哪里写错了,或者重定向规则需要配合SSL做特殊处理?

备注:内容来源于stack exchange,提问作者Robert Ellis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.17 09:14:35