Question

input : domainname.com/name

output : domainname.com/page.aspx?n=name

I have tried the below code.

<rewrite>
    <rules>
        <rule name="RedirectToWWW" stopProcessing="true">
            <match url=".*" ignoreCase="true" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="^domain.com$" />
            </conditions>
            <action type="Redirect" url="page.aspx?n={R:0}" redirectType="Permanent" />
        </rule>
    </rules>
</rewrite>

It works cool. But if I enter the domain name only, that also rewrite.how to avoid this problem?

No correct solution

OTHER TIPS

Oh my god ! finally got the solution.
<rewrite>
    <rules>
        <rule name="RedirectToWWW" stopProcessing="true">
            <match url="^(.+)$" />
        <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            </conditions>
            <action type="Redirect" url="page.aspx?n={R:0}"/>
        </rule>
    </rules>
</rewrite>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top