我想將http://domain.com
重定向到https://www.domain.com
。我成功地重定向http
到https
像這樣(在default-ssl.conf
文件):使用https連接重定向非www的http請求www域
<VirtualHost domain.com:80>
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/?(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</VirtualHost>
<VirtualHost _default_:443>
RewriteEngine on
ServerAdmin [email protected]
ServerName domain.com:443
ServerAlias www.domain.com
DocumentRoot /var/www/html
</VirtualHost>
但是,當我不www
鍵入我的域名,我得到錯誤信息This site is untrusted, the certificate is only valid to <www.domain.com>
我試圖在網絡上許多提出瞭解決方案,但它不起作用。 我的環境:
- 的Ubuntu 14.04
- 的Apache2
- 爲< 「www.domain.com」>(通用名)頒發的SSL
我不知道爲什麼我放棄投票,但無論如何感謝:) – Engineeroholic
我沒有downvote,但我想這是downvoted,因爲你可能沒有足夠的努力,現有的答案。如果您搜索本網站(頁面右上角)「www非www證書重定向」(甚至Google),您會發現一些非常相似的問題(如果不是精確重複的),特別是[這一個,作爲第一個結果](http://stackoverflow.com/a/10726167/372643),雖然不是嚴格的重複,但它有一個答案,告訴你爲什麼你會得到這個證書錯誤信息。 – Bruno
這是完美的伴侶:)但相信我我在過去3天搜索了一個答案,我在這裏找到的答案是唯一的工作。這可能會幫助其他人在未來,誰知道! – Engineeroholic