Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Url重写通过测试但未重定向_Url_Url Rewriting - Fatal编程技术网

Url重写通过测试但未重定向

Url重写通过测试但未重定向,url,url-rewriting,Url,Url Rewriting,我在我的iis中安装了URL重写模块2,我有这个规则 <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="ASPX to ASP Redirect" stopProcessing="true">

我在我的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以
.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>