https 子域名始终重定向到主域名

https 子域名始终重定向到主域名

我在 https ssl 上有主域名,但在 http 上有 2 个子域名。像主域名一样

https://expamle.com

子域名

http://s1.example.com 
http://s2.example.com 

问题是当使用 http 打开子域名时,它工作正常,但是当使用 https 打开时,它显示主域名但域名相同。请告诉我它的 httaccess 规则是什么或 apache confiq 是什么。我希望任何使用 https 打开的子域名都能正常工作,并且它会自动重定向 http

答案1

您可以在 .htaccess 中设置以下规则,将 s1.example.com 重定向到https://example.com

# subdomain to https

RewriteCond %{HTTP_HOST} ^(www\.)\?s1\.example\.com$ [NC]

RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L,NE]

相关内容