Asp.net 问题重定向与IIS url重写

Asp.net 问题重定向与IIS url重写,asp.net,wordpress,iis,url-rewriting,Asp.net,Wordpress,Iis,Url Rewriting,我有一个Asp.Net网站,它的子目录中也有一个WordPress博客。我在尝试创建重定向规则时遇到问题 我在web.config中有此规则: <rule name="Remove trailing slash"> <match url="^(.*(?!/blog/).*)$" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile

我有一个Asp.Net网站,它的子目录中也有一个WordPress博客。我在尝试创建重定向规则时遇到问题

我在web.config中有此规则:

    <rule name="Remove trailing slash">
      <match url="^(.*(?!/blog/).*)$" />
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      </conditions>
      <action type="Redirect" redirectType="Permanent" url="{R:1}" />
    </rule>

博客主页的作用是:

不起作用的是:

由于某些原因,该页面没有正确重定向(或循环)


关于如何纠正这一点,有什么想法吗?

我想试试下面的方法

<rule name="Remove trailing slash">
  <match url="^(.*)/$" />
  <conditions>
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    <add input="{HTTP_HOST}" pattern"^.*/blog/.*$" negate="true" />
  </conditions>
  <action type="Redirect" redirectType="Permanent" url="{R:1}" />
</rule>

我必须对原始语法进行更改,以使其适用于我。原始语法使用服务器变量[HTTP_HOST],但是blog连接到站点并且是它自己的实体,因此我需要使用[PATH_INFO],因为“blog”不是主机名的一部分。