[英]MVC IgnoreRoute /?_escaped_fragment_= to continue Reverse Proxy with IIS ARR
[英]IIS Reverse Proxy using ARR having problems with directory levels
我正在設置IIS 7.5來為我的站點的子目錄執行反向代理。
這是web.config url-rewrite:
<clear />
<rule name="Reverse Proxy to Community" stopProcessing="true">
<match url="^community/qa/(.*)" />
<action type="Rewrite" url="http://xxx.xxx.xxx.xxx/{R:1}" logRewrittenUrl="true" />
</rule>
ip地址指向一個帶有apache和django站點的聯網linux盒子。
我想要的是
所有請求/ community / qa / *都被重定向到指定的內部IP。
怎么了
/ community / qa / - 給出404(在主IIS服務器上)
/ community / qa / questions / - 給出404(在主IIS服務器上)
- 但 -
/ community / qa / questions / ask / Works !!!
/ community / qa / questions / unanswered / Works !!
所以它似乎適用於從起點開始的2個子目錄的所有URL。
這對我來說似乎很奇怪,我無法弄明白。
在此先感謝您的幫助。
我很確定在你的情況下問題出在UrlRoutingModule
設置中。 如果您查看Ordered View中的IIS模塊安裝程序,您將看到UrlRoutingModule
位於更高位置,然后放置Rewrite
和ApplicationRequestRouting
模塊。 這意味着,如果您的應用程序中有ASP.NET MVC的Route-setup。 此設置將影響服務器攔截它們並將它們轉發到MVC-Route-Handler的請求,而不允許反向代理執行它的工作。 例如,如果您有這樣的常見路由設置:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
在你的情況下/community/qa/
和/community/qa/questions/
不起作用,因為它會匹配給定的Url模式,並且會被解釋為:
/ community / qa / ---> Controller =“ community ”,Action =“ qa ”
/ community / qa / questions / ---> Controller =“ community ”,Action =“ qa ”,參數:Id =“ questions ”
如果你沒有這樣的控制器和動作,你將得到Http 404 Not Found。
/community/qa/questions/ask/
和/community/qa/questions/unanswered/
會起作用,因為它們與您系統中的任何UrlRouting模式都不匹配。
如此簡單的解決方案是添加您的UrlRouting配置(當Web應用程序啟動時)忽略您的網址規則:
routes.IgnoreRoute("community/qa/{*pathInfo}");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.