Url Rewrite 重定向 - IIS 7

I'm using ASP.NET 3.5 with IIS 7 with the URL Rewrite Module 2.0 installed.

When I create the first test rewrite rule:

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

It works perfectly (http://www.myapp.com/w/123/test -> http://www.myapp.com/article.aspx?id=123).

BUT, when I try to use it on a domain that I own, it doesn't work. I assume that something in my syntax is wrong. Here is what i'm trying to do:

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

When I try to browse http://www.my-domain.com I expect to be redirected to the article.aspx page, which I don't, I just get 404 page not found.

How should I write a rule for a domain and not for a path ?

Thanks in advance, Gal.

 

<rewrite>
<rules>
<rule name="static_file_auto_version">
<match url="^/(scripts|styles|images)/(.*?)\.[0-9]+\.(css|js|gif|png|jpg)" />
<action type="Rewrite" url="/{R:1}/{R:2}\.{R:3}" />
</rule>
</rules>
</rewrite>

可我访问http://localhost/styles/base-mini.222.css还是返回404

未经允许不得转载:Url Rewrite 重定向 - IIS 7

网友评论(2)

安装URL Rewrite 组件可以直接在iis管理器里面去添加规则!不错
Eagle 1970-01-01 08:33 回复
iis7在eb.config里弄重定向,感觉还是挺方便的
收狗 1970-01-01 08:33 回复


枫叶落 -技术学习交流--用心学习--用心记录!

联系我