Redirect with URLRewrite based on QueryString

Consider a situation where you need to redirect your Application to the Error page when you receive a particular value in your query string. This can be done using URL Rewrite with an inbound rule either directly in IIS or add rules directly in your web.config.

Below configuration can be added in web.config:

			<rule name="BlockQS" enabled="true" stopProcessing="true">
				<match url=".*" />
							<add input="{QUERY_STRING}" pattern="P=abc" />
				<action type="Redirect" url="" appendQueryString="false" />

If you check directly under IIS URLRewrite feature for your website, it would look like this:

URL Rewrite

Now, when you try to access, it would redirect to the configured error page.

To install URL Rewrite, follow the link.