【问题标题】:IIS Url redirect match patternIIS URL 重定向匹配模式
【发布时间】:2016-11-18 10:10:12
【问题描述】:

我在配置文件中重定向 URL。这就是我正在做的事情:

<rule name="award temp redirect"  stopProcessing="true">
    <match url="(.*?)/?award.aspx$" />
    <action type="Redirect" url="http://www.abc.com.au/award.aspx" redirectType="Temporary" />
</rule>

这对/award.aspx 工作正常,但我也想为/awards/award 添加。目前我为/awards/award 创建了单独的规则。

我可以将这两个添加到一个匹配中吗?如果 URL 是 /award.aspx/award/awards 则重定向到 http://www.abc.com.au/award.aspx

【问题讨论】:

    标签: url iis iis-7 url-rewrite-module


    【解决方案1】:

    match 接受 url 值的正则表达式。试试:

    <match url="(.*?)/?awards?(\.aspx)?$" />
    

    这将匹配 awardaward.aspxawardsawards.aspx

    更新以匹配/test

    <match url="(.*?)/?(awards?|test)(\.aspx)?$" />
    

    这只是一个regular expression。你可以匹配任何你想要的。

    【讨论】:

    • 谢谢,如果我也想添加 testaward 或 testaward.aspx 怎么办
    • 抱歉它不是 testawards 我想匹配它的 /test 或 /test.aspx 抱歉混淆@lorond
    猜你喜欢
    • 1970-01-01
    • 2019-05-30
    • 1970-01-01
    • 2013-01-21
    • 1970-01-01
    • 1970-01-01
    • 2012-05-12
    • 2019-11-17
    • 2023-01-10
    相关资源
    最近更新 更多