iis7.5为子虚拟应用程序重写500.52



我刚刚从IIS6 svr2003迁移到IIS7.5服务器2008r2,并安装了url重写。这一切都很好。有问题的网站很大,在.net 2集成管道下运行。目前无法在.net 4中重做。我是个新手,在这里有点力不从心。我真的很想使用重写功能,但我也需要子应用程序来工作。如有任何帮助,我们将不胜感激。

但是,来自外部供应商的子虚拟应用程序在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>

正如您所猜测的,最简单的方法是在子应用程序中使用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>

最新更新