0
votes

I have some old URLs in a forum application points to http://mydomain.tld/showthread.php?p=xxxx where xxxx is the an integer id.

My new forum application uses viewtopic.php?p=xxxx and I want to handle this using IIS web.config rewrite rules.

I have tried to add the last rule as the following:

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

                <!-- this for change from showthread.php to viewtopic.php -->
                <rule name="Rewrite" stopProcessing="true">
                    <match url="(.*)showthread\.php" />
                    <action type="Rewrite" url="viewtopic\.php" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>

However, it does not able to redirect to the viewtopic.php. Any suggestion?

1

1 Answers

0
votes

I have to enable httpRedirect in the IIS. Then I used this redirect rule in the web.config at the root of my forum:

<httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
         <add wildcard="*showthread.php" destination="/viewtopic.php?$P" />
</httpRedirect>