雲虛擬主機配置多個域名網站
//配置檔案:web.config
建立資料夾放置專案;(可新增多個)
//host1
//host2
//host3
注:放置專案時,開啟網站執行時,如果出現樣式載入不出來,圖片載入不出來時,表明路徑引用錯誤,必須從根目錄開始引入
(解決辦法,把css、js、img等放到一個資料夾裡引入,如static index放置原來位置;、如:static/csss/A.css)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="站點1">
<match url="^$" ignoreCase="false"/>
<conditions>
<add input="{HTTP_HOST}" pattern="^www.6566880.com$"/>
</conditions>
<action type="Rewrite" url="/host1/"/>
</rule>
<rule name="站點1靜態目錄">
<match url="^([static|\.\/static].*?)$" ignoreCase="true"/>
<conditions>
<add input="{HTTP_HOST}" pattern="^www.6566880.com$"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true"/>
</conditions>
<action type="Rewrite" url="host1/{R:0}"/>
</rule>
<rule name="站點2">
<match url="^$" ignoreCase="false"/>
<conditions>
<add input="{HTTP_HOST}" pattern="^www.6668289.com$"/>
</conditions>
<action type="Rewrite" url="/host2/"/>
</rule>
<rule name="站點2靜態目錄">
<match url="^([static|\.\/static].*?)$" ignoreCase="true"/>
<conditions>
<add input="{HTTP_HOST}" pattern="^www.6668289.com$"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true"/>
</conditions>
<action type="Rewrite" url="/host2/{R:0}"/>
</rule>
<rule name="站點3">
<match url="^$" ignoreCase="false"/>
<conditions>
<add input="{HTTP_HOST}" pattern="^www.garangame.com$"/>
</conditions>
<action type="Rewrite" url="/host3/"/>
</rule>
<rule name="站點3靜態目錄">
<match url="^([static|\.\/static].*?)$" ignoreCase="true"/>
<conditions>
<add input="{HTTP_HOST}" pattern="^www.garangame.com$"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true"/>
</conditions>
<action type="Rewrite" url="/host3/{R:0}"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>