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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.