url rewriting – IIS URL Rewrite not redirecting pages

Question

Background:

I am trying to redirect pages from one WordPress site to another, the reason being the company is rebranding so the old site has the old name and the new site has the new name and we want to make sure visitors are redirected to the new site/branding if they go to the old site.

The sites are on Windows Server 2019 servers with IIS and I’m using the URL Rewrite module which I normally don’t have any issues with.

Issue:

The redirect is completely ignored when I browse to the old site using a URL I know should be redirecting i.e. https://theoldsite.co.uk/about-us

<rule name="Test" stopProcessing="true">
<match url="about-us" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="https://thenewsite.co.uk/aboutus" />
</rule>

The whole web.config file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
                <clear />
                <rule name="WordPress: http://theoldsite.co.uk" patternSyntax="Wildcard">
                    <match url="*" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                </rule>
                <rule name="HTTPS" patternSyntax="Wildcard" stopProcessing="true">
                    <match url="*" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="off" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST URI}" redirectType="Found" />
                </rule>
                <rule name="Test" stopProcessing="true">
                    <match url="about-us" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Redirect" url="https://thenewsute.co.uk/aboutus" />
                </rule>
    </rules>
    </rewrite>
  </system.webServer>
</configuration>

Is there some voodoo going on in WP, maybe something to do with the Permalinks?

Any help gratefully received.

Rob

0
RobC_CTL 4 months 2022-07-29T08:50:40-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse