【问题标题】:Url Rewrite Pass Test But Not Redirecting网址重写通过测试但不重定向
【发布时间】:2012-11-07 23:44:38
【问题描述】:

我在我的 iis 中安装了一个 URL 重写模块 2,我有这个规则

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="ASPX to ASP Redirect" stopProcessing="true">
                    <match url="([_0-9a-z-\.]+).com/([_0-9a-z-]+).aspx$" />
                    <action type="Redirect" url="http://{R:1}.com/{R:2}.asp" appendQueryString="true" logRewrittenUrl="false" redirectType="Permanent" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

基本上我想要的是创建匹配的东西,如 www.test.com/default.aspx 并将其重定向到它的 asp 版本,所以当我输入 www.test.com/default.aspx 时,它将重定向到 www.test .com/default.asp.

不知道这是怎么回事。

【问题讨论】:

    标签: url url-rewriting


    【解决方案1】:

    域名不是与您的正则表达式匹配的 URL 的一部分。域名是什么真的很重要吗?我想说,只要 URL 以.aspx 结尾,它就应该重定向到以.asp 结尾的同一页面。这很容易做到:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="ASPX to ASP Redirect" stopProcessing="true">
                        <match url="(.*)\.aspx$" />
                        <action type="Redirect" url="/{R:1}.asp" appendQueryString="true" redirectType="Permanent" />
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>
    

    【讨论】:

      猜你喜欢
      • 2014-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多