简体   繁体   中英

Redirect rule in UrlRewrite module not working as expected IIS

the need is to redirect every non www hit to www urls and for doing that i have following rule

<rule name="WWW" enabled="true" stopProcessing="true">
        <match url="(.*)" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{HTTP_HOST}" pattern="^domain\.com$" />
        </conditions>
        <action type="Redirect" url="http://www.{HTTP_HOST}/{R:1}" />
    </rule>

what is does right now- it redirects every hit of non www url to my home page (www.domain.com) Expected- it should redirect domain.com/subpage to www.domain.com/subpage

you can try this,it's work for me

<rule name="www" >
    <match url="(.*)" ignoreCase="true" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^example\.com" />
    </conditions>
    <action type="Redirect" url="http://www.example.com/{R:1}" redirectType="Permanent" />
</rule>

the problem was with my New HAProxy LB cluster which was doing some sort of redirection with its own, redirect rule is fine. fixed it with the help of IT

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