ASP.NET / IIS7 Url重写映射不起作用 [英] ASP.NET / IIS7 Url Rewrite maps not working

查看:866
本文介绍了ASP.NET / IIS7 Url重写映射不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照说明学习IIS的网页,为我的asp.net应用程序添加带有重写映射的静态重定向。

I've followed the instructions Learn IIS's webpage for adding static redirects with a rewrite map for my asp.net application.

以下是config:

<rule name="Redirect rule1 for Information" stopProcessing="true">
    <match url=".*" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{Information:{REQUEST_URI}}" pattern="(.+)" />
    </conditions>
    <action type="Rewrite" url="{C:1}" appendQueryString="true" />
</rule>

<rewriteMaps>
    <rewriteMap name="Information">
        <add key="/Information/CorporateSales.aspx"
             value="/KB/Information/CorporateSales" />
        <add key="/Information/ComputerRepair.aspx"
             value="/KB/Information/ComputerRepair" />
    </rewriteMap>
</rewriteMaps>

这甚至最初是由IIS管理员中的向导创建的,用于使用重写地图。

This was even originally created by the wizard in IIS's manager for using rewrite maps.

所以想法是 /Information/CorporateSales.aspx - > / KB / Information / CorporateSales 301重定向(永久移动)。

So the idea is that /Information/CorporateSales.aspx --> /KB/Information/CorporateSales with a 301 redirect (MOVED PERMANENTLY).

但是我只是加载了原始的aspx页面(我们将在以后删除)。我甚至删除了文件,因为它默认为现有资源,而我只是得到一个没有重定向的普通404.

However I'm just getting the original aspx page (Which we're removing later) loading. I've even deleted the file incase it was defaulting to an existing resource, and with that i just get a plain 404 without the redirect.

任何人都有想法?

让我澄清一下:

重写模块工作,它已安装并正在运行。我的标准正则表达式规则运行良好。但是我的重写地图没有。

Rewrite module works, it's installed and running. My standard regex rules work nicely. But my rewrite map does not.

推荐答案

这篇文章 http://www.iis.net/learn/extensions/ url-rewrite-module / using-rewrite-maps-in-url-rewrite-module 和下面的代码为我工作。

This article http://www.iis.net/learn/extensions/url-rewrite-module/using-rewrite-maps-in-url-rewrite-module and code below worked for me.

<rewrite>
    <rules>
        <rule name="Redirect rule1 for RedirectURLs">
            <match url=".*" />
            <conditions>
                <add input="{RedirectURLs:{REQUEST_URI}}" pattern="(.+)" />
            </conditions>
            <action type="Redirect" url="{C:1}" appendQueryString="false" />
        </rule>
    </rules>
    <rewriteMaps>
        <rewriteMap name="RedirectURLs">
            <add key="/privacy.php" value="/privacy" />
        </rewriteMap>
    </rewriteMaps>
</rewrite>

这篇关于ASP.NET / IIS7 Url重写映射不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆