Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.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重写到域-ASP.NET\IIS 7_Asp.net_Iis 7_Url Rewriting - Fatal编程技术网

正在创建Url重写到域-ASP.NET\IIS 7

正在创建Url重写到域-ASP.NET\IIS 7,asp.net,iis-7,url-rewriting,Asp.net,Iis 7,Url Rewriting,我正在使用ASP.NET 3.5和安装了URL重写模块2.0的IIS 7 当我创建第一个测试重写规则时: <rewrite> <rules> <rule name="Test rule1" patternSyntax="ExactMatch"> <match url="w/123/test" /> <action type="Rew

我正在使用ASP.NET 3.5和安装了URL重写模块2.0的IIS 7

当我创建第一个测试重写规则时:

    <rewrite>
        <rules>
            <rule name="Test rule1" patternSyntax="ExactMatch">
                <match url="w/123/test" />
                <action type="Rewrite" url="article.aspx?id=123" />
            </rule>           
        </rules>
    </rewrite>

)

但是,当我尝试在我拥有的域上使用它时,它不起作用。我假设我的语法中有错误。以下是我想做的:

            <rule name="Test Rule2" patternSyntax="ExactMatch">
                <match url="http://www.my-domain.com" />
                <action type="Rewrite" url="article.aspx?id=123" />
            </rule> 

当我尝试浏览
http://www.my-domain.com
我希望被重定向到
article.aspx
页面,但我没有,我只是找不到404页面

我应该如何为域而不是路径编写规则


提前感谢,Gal.

规则与web.config所在的位置相关。您不需要为规则指定任何域。/>的输入将始终是URL路径,没有查询字符串,也没有前导斜杠。也就是说,如果你要求”http://www.my-domain.com/“输入将是”“。”。如果你要求”http://www.my-domain.com/w/123/test,则输入为“w/123/test”

如果您只是浏览到“默认文档”,IIS中的“默认文档”模块将尝试将您的请求重写为类似“的内容”,这与您的规则不匹配。确保禁用默认文档模块

如果这不起作用,URL重写具有跟踪功能,您可以在其中逐步查看工作流:


注意:对于服务器规则,输入URL始终包含前导斜杠。

不,仍然是404。谢谢你的评论。