IIS URL 重写

2024-01-24

好吧,这让我发疯......我正在尝试像这样重写我的网址:

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

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

谁能帮我解决这个问题吗?用户界面中的术语非常令人困惑。

Thanks.


我找到了答案:

<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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

IIS URL 重写 的相关文章

随机推荐