« Previous Next »

Not Answered Thread: help with IIS7 rewrite rule (rewrite whole QS as 1 string)

Last post 01-19-2009 2:10 PM by ruslany. 3 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (4 items)

Sort Posts:

  • 01-16-2009, 8:36 AM

    • mike123
    • Top 500 Contributor
    • Joined on 07-22-2002, 3:45 PM
    • Posts 19

    help with IIS7 rewrite rule (rewrite whole QS as 1 string)

    Hi,

    I'm attempting to do a rewrite rule and having some difficulty.  I have done dozens of rewrite rules before, but this ones a little different because it involves and  ampersand  ("&")


    I want to rewrite everything after the "?" in the below URL to another page, so basically the whole QS as one string

     jsbox.js?var1=afd&param2=fddss&notSureAllValues=fff

    to

    jsbox.aspx?{R:1}

    where {R:1}  is equal to the whole querystring above.   ("var1=afd&param2=fddss&notSureAllValues=fff")

     Am I able to rewrite like this ?

    Any help much appreciated, been stuck on this for over a week cant seem to find any articles !

    Thanks again

    mike123

  • 01-16-2009, 8:09 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 7:38 PM
    • Redmond, WA
    • Posts 664

    Re: help with IIS7 rewrite rule (rewrite whole QS as 1 string)

    So basically you want to rewrite from jsbox.js to jsbox.aspx and keep the original query string. In that case this rule should work for you:

     <rule name="Rewrite" patternSyntax="Wildcard">
             <match url="jsbox.js" />
             <action type="Rewrite" url="jsbox.aspx" appendQueryString="true" />
     </rule>

    If you want to make rewriting decisions based on the query string then you would need to modify the rule as below:

    <rule name="Rewrite" patternSyntax="Wildcard">
               <match url="jsbox.js" />
              <conditions>
                 <add input="{QUERY_STRING}" pattern="some pattern here" />
             </conditions>
             <action type="Rewrite" url="jsbox.aspx" />
    </rule>

    http://ruslany.net
  • 01-18-2009, 9:19 AM In reply to

    • mike123
    • Top 500 Contributor
    • Joined on 07-22-2002, 3:45 PM
    • Posts 19

    Re: help with IIS7 rewrite rule (rewrite whole QS as 1 string)

    Hi Ruslany,

    That works perfectly.  I Just realized I need to do it on my IIS6 box too, but I don't think this appendQueryString option exists ?

    Any ideas?

    Much appreciated!

    Thanks!

    mike123

  • 01-19-2009, 2:10 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 7:38 PM
    • Redmond, WA
    • Posts 664

    Re: help with IIS7 rewrite rule (rewrite whole QS as 1 string)

    URL rewrite module is only supported on IIS 7 and further. To do the same on IIS 6 you have to use some other URL rewriting module, for example ISAPI Rewrite.

    http://ruslany.net
Page 1 of 1 (4 items)
Microsoft Communities