How can I make this rewrite rule so that it can accept querystring?


I have a url rewrite rule that uses map method.

            <rewriteMap name="Pages">
                <add key="/search" value="/search.asp" />

            <rule name="Rewrite rule1 for Pages">
                <match url=".*" />
                    <add input="{Pages:{REQUEST_URI}}" pattern="(.+)" />
                <action type="Rewrite" url="{C:1}" appendQueryString="true" />

My problem is when I use this page like below, I get error:


I get HTTP Error 404.0 - Not Found

Detailed Error Information: Module IIS Web Core Notification MapRequestHandler Handler StaticFile Error Code 0x80070002 Requested URL http://localhost:85/search?keyword=math Physical Path D:\webs\V5ST\HTML\search Logon Method Anonymous Logon User Anonymous

How can I make this so that whatever querystring is passed to search.asp?

asked on Stack Overflow May 15, 2019 by Savaş Zorlu • edited May 17, 2019 by Savaş Zorlu

1 Answer


You could use below rewrite rule:

 <rule name="query string redirect" enabled="true" stopProcessing="true">
                <match url="(.*)" />
                    <add input="{REQUEST_URI}" pattern="search\?(.*)" />
                <action type="Rewrite" url="http://localhost:132/search.asp?{C:1}" appendQueryString="false" />

Regards, Jalpa

answered on Stack Overflow May 17, 2019 by Jalpa Panchal

User contributions licensed under CC BY-SA 3.0