url rewriting - IIS URL Rewrite - if query parameter(s) is missing -


so "not everyday requirement" today :)

i want create rule redirect other page if query parameters missing.

i found few examples rewrite/redirect if parameters exists, how go if want check if dont exists?

for example, test if parameters exist , redirect based on that:

        <rule name="redirectuserfriendlyurl1" stopprocessing="true">             <match url="^$" />             <conditions>                 <add input="{query_string}" pattern="^lon=([^=&amp;]+)&amp;lat=([^=&amp;]+)&amp;zoom=([^=&amp;]+)$" />             </conditions>             <action type="redirect" url="/{c:1}/{c:2}/{c:3}" appendquerystring="false" />         </rule> 

how can change rule test if not exist?

^((?!regex).)*$ regular expression not contain regex. read more here http://bloggernitin.blogspot.in/2007/12/regex-for-doesnt-contain.html

if looking lon=xyz doesn't exists in params use regex ^(?!lon=(xyz)) check if lon param not there @ start of string

more examples -

in case have case zoom param there query string , lat/lon missing
e.g. querystring a) "lat=23&zoom=10" b) "zoom=13"

regex - ^(?!lon=.)(?!lat=.)zoom=([^=&]+)
result - a) no match b) match $1= 13

can give default value other params.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -