1

I'm trying to rewrite my URL

FROM https://localhost/details.html?page=2

TO https://localhost/license

When I use Redirect, it works perfectly when I request the URL https://localhost/license, but the URL changes to https://localhost/details.html?page=2.

When I use Rewrite, the URL remains https://localhost/license, but the "redirecting" goes to details.html (static html) without parameter page=2 (dynamically generated), even when I set appendQueryString to TRUE.

Redirect code (Working):

   <rewriteMap name="StaticRewrites">
            <add key="/license" value="/details.html?page=2" />
        </rewriteMap>
    </rewriteMaps>

    <rules>
                <rule name="Redirect Rule">
                <match url=".*" />
                <conditions>
                <add input="{StaticRewrites:{URL}}" pattern="(.+)" />
                </conditions>
                <action type="Redirect" url="{C:1}" appendQueryString="true" />
                </rule>
    </rules>

Rewrite code (Not Working):

   <rewriteMap name="StaticRewrites">
            <add key="/license" value="/details.html?page=2" />
        </rewriteMap>
    </rewriteMaps>

    <rules>
                <rule name="Redirect Rule">
                <match url=".*" />
                <conditions>
                <add input="{StaticRewrites:{URL}}" pattern="(.+)" />
                </conditions>
                <action type="Rewrite" url="{C:1}" appendQueryString="true" />
                </rule>
    </rules>

Does anyone knows how can I configure Rewrite method to keep the URL https://localhost/license but to show the dynamic page https://localhost/details.html?page=2?

berndbausch
  • 1,033
  • 8
  • 12

0 Answers0