Iis
將傳入請求重定向到 IIS 7 中的特定 URL
我在 IIS HTTP Redirect 功能中找到了,但我只能將所有傳入請求重定向到特定目的地。是否可以將傳入請求重定向到 IIS 中的特定 URL?例如:
my.domain.com/blog/about -> other.domainxyz.com/site/about my.domain.com/blog/post/5 -> other.domainxyz.com/site/5
更新
這是 web.config 的樣子:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="home" stopProcessing="true"> <match url="^$" /> <action type="Redirect" url="http://yojimbo87.github.com/" /> </rule> <rule name="about" stopProcessing="true"> <match url="^Blog/About$" /> <action type="Redirect" url="http://yojimbo87.github.com/about/about.html" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
儘管有 HTTP 重定向,但我還沒有在角色服務中找到 URL 重寫模組。
此規則會將特定傳入請求重定向到特定 URL:
<system.webServer> <rewrite> <rules> <rule name="Redirect Specific Page" stopProcessing="true"> <match url="^blog/post/5$" /> <action type="Redirect" url="http://other.domainxyz.com/site/5" /> </rule> </rules> </rewrite> </system.webServer>
更新: 我已經將它們合併在一起——只需用真實的 URL 更新它:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="home" stopProcessing="true"> <match url="^$" /> <action type="Redirect" url="http://yojimbo87.github.com/" /> </rule> <rule name="about" stopProcessing="true"> <match url="^Blog/About$" /> <action type="Redirect" url="http://yojimbo87.github.com/about/about.html" /> </rule> <rule name="Redirect Specific Page" stopProcessing="true"> <match url="^blog/post/5$" /> <action type="Redirect" url="http://other.domainxyz.com/site/5" /> </rule> </rules> </rewrite> </system.webServer> </configuration>