Vishnu Vankayala
Vishnu Vankayala

Reputation: 129

IIS URL redirect

I have installed wordpress on azure app services and trying to set up a redirect for the base URL.

when someone enters "https://website.co/integration-resources" or "https://website.co/integration-resources/" it should redirect to https://website.co/integrations

however, when someone types https://website.co/integration-resources/add-to-cart it should allow.

<rule name="Configure Python" stopProcessing="true">
          <match url="(.*)" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_URI}" pattern="^/static/.*" ignoreCase="true" negate="true" />
            <add input="{URL}" pattern="^/blog/.*" ignoreCase="true" negate="true" />
            <add input="{URL}" pattern="^/blog" ignoreCase="true" negate="true" />
            <add input="{URL}" pattern="^/integration-resources/.*" ignoreCase="true" negate="true" />
          </conditions>
          <action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="true"/>
        </rule>
        <rule name="Configure Python 1" stopProcessing="true">
          <match url="(.*)" ignoreCase="false" />
          <conditions>
            <add input="{URL}" pattern="^/integration-resources" ignoreCase="true" negate="true" />
          </conditions>
          <action type="Rewrite" url="handler.fcgi/integrations" appendQueryString="true"/>
        </rule>
      </rules>

Upvotes: 0

Views: 92

Answers (2)

Aaron Chen
Aaron Chen

Reputation: 9950

This would work if you add a rule like this:

<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
    <system.webServer>

        <rewrite>
            <rules>
                <rule name="Redirect for the base URL" stopProcessing="true">
                    <match url="^integration-resources[\/]?$" />
                    <action type="Redirect" url="integrations" />
                </rule>
            </rules>
        </rewrite>

    </system.webServer>
</configuration>

Upvotes: 1

Victor Leontyev
Victor Leontyev

Reputation: 8736

You should add this rule above your rules

<rule name="integration-resources redirect" stopProcessing="true">
    <match url="^integration-resources/?$" ignoreCase="false" />
    <action type="Redirect" url="/integrations" appendQueryString="true"/>
</rule>

Regexp ^integration-resources/?$ will match only if your URL is integration-resources or integration-resources/

Upvotes: 0

Related Questions