简体   繁体   中英

IIS Url Rewrite Redirect not accepting regex

Im trying to create a redirect in my IIS for a site. It works with the wildcard setting but i cant get it to redirect with regex. The built in test tool shows that the correct URLs are passed with this regex and the others dont pass, yet nothing happens when the rule is applied. Are there any faults or limitations with the URL redirect that im not aware of?

    <rewrite>
        <rules>
            <rule name="My Redirect" patternSyntax="ECMAScript" stopProcessing="true">
                <match url=".*(site\.com/)(\w{2})/additive\-technology/" />
                <action type="Redirect" url="http://www.anotherSite.com/" />
            </rule>
        </rules>
    </rewrite>

The answer is that the pattern test tool in IIS will match regexes that wont match on real requests. In this case i did not know that the matching is only done with the part of the URL after the domain. So the regex that works for real requests in this case is:

.*(\w{2})/additive\-technology/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM