2
我想始終使用https並擁有一個規範域。問題是,當我與輔助域名進行https連接時,一切都會破裂,因爲證書是針對主域的。有沒有辦法解決這個問題,還是我必須購買證書,而不僅僅是規範域?如何配置規範主機名並強制https與Apache?
我 「/etc/apache2/apache2.conf中」 的有關部分
# Canonical hostname and always use https
<IfModule mod_rewrite.c>
RewriteEngine On
# force https on primary host (works fine)
# http://primary-host.com -> https://primary-host.com
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^primary-host\.com$
RewriteRule (.*) https://primary-host.com%{REQUEST_URI}
# force https and redirect to primary host (works fine)
# http://secondary-host.com -> https://primary-host.com
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^secondary-host\.com$
RewriteRule (.*) https://primary-host.com%{REQUEST_URI}
# FAIL: Certificate doesn't match and "Bad Request (400)" if accepted!
# https://secondary-host.com -> https://primary-host.com
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^secondary-host\.com$
RewriteRule (.*) https://primary-host.com%{REQUEST_URI}
</IfModule>