phpweb.leven.com.cn → localhost:8081 (PHP)levenblog.leven.com.cn → localhost:8080 (LevenBlog)realblog.leven.com.cn → leven.com.cn (公網站點)localhost/leven → leven.com.cn (路徑代理)
LevenWeb,綁定 Port 80、主機名留空 (預設網站)。web.config)。
phpweb,Pattern: ^(.*)$。
{HTTP_HOST} Matches ^phpweb.leven.com.cn$。
https://localhost:8081/{R:1}。
<rewrite>
<rules>
<rule name="phpweb">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^phpweb.leven.com.cn$" />
</conditions>
<action type="Rewrite" url="https://localhost:8081/{R:1}" />
</rule>
</rules>
</rewrite>
<rule name="levenblog">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^levenblog.leven.com.cn$" />
</conditions>
<action type="Rewrite" url="https://localhost:8080/{R:1}" />
</rule>
<rule name="realblog">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^realblog.leven.com.cn$" />
</conditions>
<action type="Rewrite" url="https://leven.com.cn/{R:1}" />
</rule>
代理後 CSS/JS/圖片/連結路徑變為 /leven/xxx,但上游站點輸出絕對路徑 /xxx,導致資源 404、樣式錯亂。


<rule name="leven.com.cn">
<match url="^leven/(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^localhost$" />
</conditions>
<action type="Rewrite" url="https://leven.com.cn/{R:1}" />
</rule>

Add application prefix。filterByTags="A,Img,Script,Link" pattern="^/(.*)$"。{URL} Matches ^/leven/.*。/leven/{R:1}。<outboundRules>
<rule name="Add application prefix">
<match filterByTags="A,Img,Script,Link" pattern="^/(.*)$" />
<conditions>
<add input="{URL}" pattern="^/leven/.*" />
</conditions>
<action type="Rewrite" value="/leven/{R:1}" />
</rule>
</outboundRules>
重新整理頁面,CSS/JS/圖片/連結全部正常載入。

<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="phpweb"><match url="^(.*)$" /><conditions><add input="{HTTP_HOST}" pattern="^phpweb.leven.com.cn$" /></conditions><action type="Rewrite" url="https://localhost:8081/{R:1}" /></rule>
<rule name="levenblog"><match url="^(.*)$" /><conditions><add input="{HTTP_HOST}" pattern="^levenblog.leven.com.cn$" /></conditions><action type="Rewrite" url="https://localhost:8080/{R:1}" /></rule>
<rule name="realblog"><match url="^(.*)$" /><conditions><add input="{HTTP_HOST}" pattern="^realblog.leven.com.cn$" /></conditions><action type="Rewrite" url="https://leven.com.cn/{R:1}" /></rule>
<rule name="leven.com.cn"><match url="^leven/(.*)$" /><conditions><add input="{HTTP_HOST}" pattern="^localhost$" /></conditions><action type="Rewrite" url="https://leven.com.cn/{R:1}" /></rule>
</rules>
<outboundRules>
<rule name="Add application prefix"><match filterByTags="A,Img,Script,Link" pattern="^/(.*)$" /><conditions><add input="{URL}" pattern="^/leven/.*" /></conditions><action type="Rewrite" value="/leven/{R:1}" /></rule>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
X-Forwarded-Proto。