1

我需要在我的网站中隐藏任何类型的页面扩展,这些扩展已经托管了 100 多个页面 asp、html 和 aspx 页面。我想隐藏所有类型的页面扩展名。我使用以下仅适用于 .aspx 的代码。不适用于 .html 和 .asp 页面扩展

<rule name="RemoveASPX" enabled="true" stopProcessing="true">
      <match url="(.*)\.aspx" />
      <action type="Redirect" url="{R:1}" />
    </rule>
    <rule name="AddASPX" enabled="true">
      <match url=".*" negate="false" />
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
      </conditions>
      <action type="Rewrite" url="{R:0}.aspx" />
    </rule>
4

2 回答 2

0

您可以(并且应该)使用 Asp.NET 提供的路由机制,在您的特定情况下使用MapPageRoute此处描述的方法:http: //msdn.microsoft.com/en-us/library/vstudio/dd329551%28v=vs。 100%29.aspx

您所看到的有关 aspx 页面的内容也可以应用于其他类型的页面,例如纯 html 或旧 asp。

于 2015-01-14T13:08:45.010 回答
0
<match url="(.*)\.(aspx|php|html)" />

<action type="Rewrite" url="{R:0}.{R:1}" />

您可以更改匹配元素的正则表达式,使其与其他扩展匹配。

于 2015-01-14T12:22:33.267 回答