【问题标题】:Why does Url Rewrite 2.0 not work?为什么 Url Rewrite 2.0 不起作用?
【发布时间】:2011-04-04 16:18:08
【问题描述】:

我正在本地 IIS 7.5 上运行一个 .net framework 4 Web 应用程序项目,并安装了 URL Rewrite 2.0 模块。

我的应用程序包含一个名为 sitemap.aspx 的页面。我希望能够将 /sitemap/ 映射到 sitemap.aspx

到目前为止,这是我的代码,但它不起作用。调用 /sitemap 后,我会看到 404 Not Found 错误屏幕。缺少什么?

   <rewrite>
        <rules>
            <rule name="LowerCaseRule1" enabled="true" stopProcessing="true">
                <match url="[A-Z]" ignoreCase="false" />
                <conditions>
                    <add input="{URL}" matchType="Pattern" pattern="^.+\.((axd)|(js)|(xaml))$" ignoreCase="true" negate="true" />
                </conditions>
                <action type="Redirect" url="{ToLower:{URL}}" redirectType="Permanent" />

            </rule>
            <rule name="RemoveTrailingSlashRule1" stopProcessing="true" enabled="true">
                <match url="(.*)/$" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                </conditions>
                <action type="Redirect" url="{R:1}" />
            </rule>
        </rules>
        <rewriteMaps>
            <rewriteMap name="test">
                <add key="/sitemap" value="sitemap.aspx"/>
            </rewriteMap>
        </rewriteMaps>
    </rewrite>

【问题讨论】:

    标签: c# asp.net iis-7.5 url-rewriting


    【解决方案1】:

    我在该部分中缺少一个条目:

    添加

            <rule name="Rewrite rule1 for test">
                <match url=".*" />
                <conditions>
                    <add input="{test:{REQUEST_URI}}" pattern="(.+)" />
                </conditions>
                <action type="Rewrite" url="{C:1}" appendQueryString="false" />
            </rule>
    

    一切正常

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-21
      • 2013-10-15
      • 1970-01-01
      • 1970-01-01
      • 2022-01-17
      • 1970-01-01
      • 2017-11-19
      相关资源
      最近更新 更多