現在的網頁走https協定已經是基本的必備,至於原本的http要如何可以讓使用者無論如何打都可以轉到你要的網址,可以使用下面的參數調整。 

<VirtualHost 你的伺服器IP:80>
<Directory 你的網頁位置>

AllowOverride All
# Options Indexes FollowSymLinks MultiViews
# Cancel Folder List View
Options FollowSymLinks MultiViews
RewriteEngine on
RewriteCond %{HTTPS} !=on
#伺服器位於內部的IP

RewriteCond %{HTTP_HOST} ^111\.111\.111\.111\$ [NC]
#伺服器開放給外面的IP

RewriteCond %{HTTP_HOST} ^111\.111\.111\.111$
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^([a-z.]+)?mydomain\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*)$ https://blog.aiso.idv.tw/$1 [L,R=301]
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R,L]
AllowOverRide None
Require all granted

</Directory>

DocumentRoot 你的網頁位置
ServerAdmin blog@YourDomain
ServerName blog.YourDomain
ErrorLog logs/httpd/blog-error.log
CustomLog logs/httpd/blog-access_log common

</VirtualHost>

<VirtualHost 你的伺服器IP:443>
<Directory 你的網頁位置>

Options FollowSymLinks MultiViews
RewriteCond %{HTTP_HOST} ^111\.111\.111\.111\/*$ [NC]
RewriteCond %{HTTP_HOST} ^111\.111\.111\.111\/*$
RewriteCond %{HTTP_HOST} ^([a-z.]+)?mydomain\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*)$ https://blog.aiso.idv.tw/$1 [L,R=301]
AllowOverride All
Require all granted

</Directory>

SSLEngine on
SSLCipherSuite HIGH
SSLCertificateFile 憑證檔案位置/fullchain.pem
SSLCertificateKeyFile 憑證檔案位置/privkey.pem
SSLCertificateChainFile 憑證檔案位置/chain.pem
ServerAdmin blog@YourDomain
addDefaultCharset UTF-8
DocumentRoot 你的網頁位置
ServerName blog.YourDomain
ErrorLog logs/httpd/blog-error.log
CustomLog logs/httpd/blog-access_log common

</VirtualHost>