2012-07-06 39 views
3

我剛從IIS6 svr2003遷移到IIS7.5 server 2008r2並安裝了url重寫。這一切都很好。有問題的網站很大,運行在.net 2集成管道下。此時無法在.net 4中重做。我是這個品牌的新手,並且在這裏有點超出我的深度。我真的很喜歡使用重寫功能,但我需要子應用程序也能工作。任何幫助,將不勝感激。iis7.5爲子虛擬應用重寫500.52

但是,來自外部供應商的子虛擬應用程序在webconfig的重寫部分存在問題。我發表評論,子虛擬作品很棒。我看着在網絡上,並試圖幾件事情:

<location path="." inheritInChildApplications="false"> 

<location path="." allowOverride="true" /> 

重寫模塊纏給我:system.web元素具有無效的子元素的位置。

我試過 正確的在子虛擬應用程序的webconfig中的system.web下,但即使重寫註釋掉 - 這給出了一個錯誤。 我可以嘗試刪除,但想知道是否有人可以給我一些關於這個問題的見解。

這裏是基本的改寫:

<rewrite> 
    <rules> 
    <rule name="RedirectUserFriendlyURL1" stopProcessing="true"> 
     <match url="^sethsBrochure.pdf$" /> 
     <conditions> 
     <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" /> 
     </conditions> 
     <action type="Redirect" url="path/path/doc.pdf" appendQueryString="false" /> 
    </rule> 
    <rule name="RewriteUserFriendlyURL1" stopProcessing="true"> 
     <match url="^sethsBrochure$" /> 
     <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
     </conditions> 
     <action type="Rewrite" url="path/path/doc.pdf" /> 
    </rule> 
    </rules> 
    <outboundRules> 
    <rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1"> 
     <match filterByTags="A, Form, Img" pattern="^(.*)path/path/doc\.pdf$" /> 
     <action type="Rewrite" value="{R:1}/ path/path/doc" /> 
    </rule> 
    <preConditions> 
     <preCondition name="ResponseIsHtml1"> 
     <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> 
     </preCondition> 
    </preConditions> 
    </outboundRules> 
</rewrite> 

回答

0

最簡單的方法是,你猜到了,在子應用中使用clearremove。例如:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
     <rewrite> 
      <rules> 
       <clear /> 
       <!-- Insert rules for this application (if any) **below** the "clear" --> 
      </rules> 
     </rewrite> 
    </system.webServer> 
</configuration> 

然而,當你在網上找到的,你也可以做到這一點使用location塊。您嘗試的問題是,位置塊需要以外的system.webServer塊,不在其中。

你寫你的努力:

<configuration> 
    <system.webServer> 
     <location path="." inheritInChildApplications="false"> 
      <rewrite> 
      ... 
      </rewrite> 
     </location> 
    <system.webServer> 
<configuration> 

相反,你需要這樣做:

<configuration> 
    <location path="." inheritInChildApplications="false"> 
     <system.webServer> 
      <rewrite> 
      ... 
      </rewrite> 
     <system.webServer> 
    </location> 
<configuration>