IIS URL重写

时间:2009-07-06 20:57:30

标签: iis url-rewriting

好的,这让我疯了......我正在尝试重写我的网址:

Now:
http://www.somedomain.com/Somepage.aspx
http://www.somedomain.com/AnotherPage.aspx

Desired:
http://www.somedomain.com/somepage/
http://www.somedomain.com/anotherpage/

任何人都可以帮我解决这个问题吗?用户界面中的术语令人困惑。

感谢。

1 个答案:

答案 0 :(得分:3)

我找到了答案:

<rewrite>
  <rules>
    <rule name="Redirect" stopProcessing="true">
      <match url="^([^\.]+)\.aspx$" />
      <conditions>
        <add input="{REQUEST_METHOD}" negate="true" pattern="^POST$" />
      </conditions>
      <action type="Redirect" url="{ToLower:{R:1}}/" appendQueryString="false" redirectType="Permanent" />
    </rule>
    <rule name="Rewrite" stopProcessing="true">
      <match url="^([^/]+)/$" />
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      </conditions>
      <action type="Rewrite" url="{R:1}.aspx" />
    </rule>
  </rules>
</rewrite>