虛擬主機怎么設(shè)置https?虛擬主機設(shè)置https,需要根據(jù)linux系統(tǒng)和windows系統(tǒng)來分別配置。在安裝好https證書后,需要在虛擬主機系統(tǒng)文件里,設(shè)置偽靜態(tài)規(guī)則,來達到所有頁面使用https路徑訪問。
linux虛擬主機系統(tǒng)下,需要在虛擬主機根目錄下,建立一個.htaccess文件,如果根目錄下已經(jīng)存在,直接在文件里編輯。在.htaccess文件里放入以下代碼(注意刪除掉注釋語句#)
<ifmodule mod_rewrite.c>
rewriteengine on
rewritecond %{http:from-https} !^on$ [nc]
rewritecond %{http_host} ^(www.)?xxx.com$ [nc] # 將xxx.com和www.xxx.com跳轉(zhuǎn)到https://www.xxx.com,防止apache子站繼承上級目錄.htaccess受影響,注釋請自行刪除,不要放入htaccess文件
rewriterule ^(.*)$ https://www.xxx.com/$1 [r=301,l]
rewritecond %{http_host} ^xxx.gotoip55.com$ # 西部數(shù)碼的虛擬主機默認(rèn)ftp上傳地址在gotoip55.com,可以將此地址也301至https://www.xxx.com
rewriterule ^(.*)$ https://www.xxx.com/$1 [r=301,l]
</ifmodule>windows虛擬主機系統(tǒng)下,需要在虛擬主機根目錄下,在web.config文件中,將偽靜態(tài)規(guī)則加入。以下是具體代碼(注意刪除掉注釋語句#)
<?xml version=1.0 encoding=utf-8?>
<configuration>
<system.webserver>
<rewrite>
<rules>
<rule name=301 stopprocessing=true>
<match url=^(.*)$ ignorecase=false />
<conditions logicalgrouping=matchall>
<add input={http_from_https} pattern=^on$ negate=true />
</conditions>
<action type=redirect url=https://www.xxx.com/{r:1} redirecttype=permanent /> # www.xxx.com對應(yīng)修改為您自已的域名,注釋請自行刪除,不要放入web.config文件內(nèi)
</rule>
</rules>
</rewrite>
</system.webserver>
</configuration>通過這些規(guī)則,就可以實現(xiàn)網(wǎng)站頁面從http向https的整體跳轉(zhuǎn),如果在執(zhí)行過程中出現(xiàn)問題,可以咨詢西部數(shù)碼技術(shù)客服,尋求技術(shù)指導(dǎo)。虛擬主機怎么設(shè)置https的介紹就到這里,如需購買虛擬主機,首推西部數(shù)碼:https://www.west.cn/services/webhosting/