URL Rewriting the path in IIS

I have a site that uses two characters in the URL path to determine the initial language e.g. https://my.company.net/Monitoring/gb displays in the English language. I want to setup a redirect for these two display the full culture code e.g. https://my.company.net/Monitoring/en-GB

This is the rule that I've tried:

<rewrite>
    <rules>
        <rule name="Monitoring gb rewrite" patternSyntax="ExactMatch" stopProcessing="true">
            <match url="https://my.company.net/Monitoring/gb" />
            <conditions />
            <serverVariables />
            <action type="Redirect" url="https://my.company.net/Monitoring/en-GB" appendQueryString="false" />
        </rule>
        </rules>
</rewrite>

I expected https://my.company.net/Monitoring/gb to redirect to https://my.company.net/Monitoring/en-GB however this rule does not have any effect: the browser URL stays at https://my.company.net/Monitoring/gb.

How can I rectify this?

Upvotes: 0

Views: 49

Answers (2)

The redirect failure was due to browser caching. The redirect works once the cache is cleared.

Upvotes: 0

Jalpa Panchal
Jalpa Panchal

Reputation: 12759

You could use below url rewrite rule.

<rule name="gb to en-gb redirect" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="ww.sample1.com" />
                    <add input="{HTTPS}" pattern="on" />
                    <add input="{REQUEST_URI}" pattern="Monitoring/gb" />
                </conditions>
                <action type="Redirect" url="https://www.sample1.com/Monitoring/en-GB" />
            </rule>

Note: use your hostname instead of the www.sample1.com.

enter image description here

Upvotes: 1

Related Questions