redirect - 在 IIS7 中重写映射 - 不重定向

标签 redirect iis-7 url-rewrite-module

我正在尝试使用名为“rewritemaps.config”的单独配置文件,其中包含我要重定向的 URL。该文件位于根目录中(与 web.config 位于同一位置)。我的 Redirects.config 文件的格式是:

<rewriteMaps>
    <rewriteMap name="Redirects">
        <add key="aspx/drvmain.aspx"
             value="http://www.newdomain.com/folder2/page2.aspx" />
        <add key="aspx/jobs_AboutUs.aspx"
             value="http://www.newdomain.com/folder1/jobs.aspx" />
        <add key="aspx/page.aspx"
             value="http://www.newdomain.com/folder1/page2.aspx" />
    </rewriteMap>
</rewriteMaps>

在我的 web.config 文件中,我有:

<system.webServer>
    <rewrite>
        <rewriteMaps configSource="rewritemaps.config" />
            <rules>
                <rule name="Redirect rules">
                    <match url=".*" />
                    <conditions>
                        <add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" />
                    </conditions>
                    <action type="Redirect" redirectType="Permanent"
                            url="{C:1}" appendQueryString="false" />
                </rule>
            </rules>
        </rewriteMaps>
    </rewrite>
</system.webServer>

在 IIS 管理器(是的,我已经安装了 URL 重写模块)中,我什至针对 redirects.config 文件中的一个 URL 测试了规则和条件,它说它有效。但是,当我尝试在浏览器中访问该 URL 时,它不会按照我指定的方式进行重定向。在 rewritemaps.config 文件中,我尝试放置完整的域,并尝试在 aspx 之前添加“/”。似乎什么都不起作用。我不确定我在这里缺少什么。

最佳答案

好吧,我成功了。是一些愚蠢的事情。在 rewritemaps.config 文件中,我在关键 URL 之前需要“/”。我知道我以前曾尝试过,但当时我一定在其他地方错过了一些东西。那好吧。现在可以了。

关于redirect - 在 IIS7 中重写映射 - 不重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14270332/

相关文章:

.htaccess - 为我的 sitemap.xml 重写规则 .htaccess

信息系统 |阻止特定于特定内部 IP 地址的页面特定 URL

http - symfony2 重定向响应

apache - 将所有内容从域 A 重定向到域 B 主页,重定向一个特定 pdf 文件除外

bash - 交换两个程序的输入和输出

asp.net-mvc-2 - ASP.NET MVC 2.0 : route request to static resource

iis - 使用 IIS 和反向代理设置 SonarQube for SSL 会引发 502 错误

regex - 将博主网址转发到自己的域网址

asp.net - Windows 7 上的等效 "aspnet_regiis -lk"是什么?

asp.net-mvc - 无法设置 SSL 供公众使用。可能的端口问题