0

Inbound IIS7 Url Rewrite Rule not working

Below is the URL Rewrite rule I've defined.

    <rewrite>
        <rules>
            <rule name="Redirect domain.co.uk to www.domain.co.uk" enabled="true" stopProcessing="true">
                <match url="^domain\.co\.uk(.*)" />
                <action type="Redirect" url="http://www.domain.co.uk{R:1}" />
            </rule>
        </rules>
    </rewrite>

When I go to domain.co.uk it's not redirecting to www.domain.co.uk. Am I doing something wrong?

1
2

Had to add a condition to get it to work. Like so...

    <rewrite>
        <rules>
            <rule name="Redirect root to www" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^domain\.co\.uk(.*)" />
                </conditions>
                <action type="Redirect" url="http://www.domain.co.uk/{R:1}" />
            </rule>
        </rules>
    </rewrite>

URL Rewrite Tips

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.