« Previous Next »

Thread: Help needed with migrating ISAPI_Rewrite 2.9 rule to IIS7 Url Rewrite

Last post 07-21-2009 2:09 PM by Xygorf. 8 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (9 items)

Sort Posts:

  • 07-20-2009, 4:40 PM

    • Xygorf
    • Not Ranked
    • Joined on 07-20-2009, 4:32 PM
    • Posts 5

    Help needed with migrating ISAPI_Rewrite 2.9 rule to IIS7 Url Rewrite

    Hi am struggling to convert this rule to IIS7 URL rewrite and I would really appreciate any help. I have tried the import, which imports successfully but states the rule is invalid: 'Invalid rule back reference. The index 3 is invalid' Here is the ISAPI Reqwrite Rule RewriteCond Host: (www\.)?(.+) RewriteRule /link(.*) /section/subsection/default.asp?query=$3 [I,L] I would really appreciate some help in what I need to do. Thanks
  • 07-20-2009, 4:56 PM In reply to

    • DanielVL
    • Top 75 Contributor
    • Joined on 10-07-2006, 6:00 PM
    • Redmond, WA, USA
    • Posts 109

    Re: Help needed with migrating ISAPI_Rewrite 2.9 rule to IIS7 Url Rewrite

    If what you really want is a back-reference to /link(.*) then please change $3 to $1

    $3 means the 3rd capture of RewriteRule but you only have one capure (plus $0). RewriteCond has two captures but those should be available using %1 and %2 (% instead of $)

    Hope that helps.

     

    Daniel Vasquez Lopez
    URL Rewrite Engine Developer
  • 07-20-2009, 5:03 PM In reply to

    • Xygorf
    • Not Ranked
    • Joined on 07-20-2009, 4:32 PM
    • Posts 5

    Re: Help needed with migrating ISAPI_Rewrite 2.9 rule to IIS7 Url Rewrite

    A typical URL would be http://mydomain.com/product/66/Supplier/Product+Name What i'm trying to do is grab the 66 and append it to that query but $1 or {R:1} as it translates in IIS7 Rule appears to contain /66/Supplier/Product+Name where as I only want the 66 Any more ideas? This rule works as is on my old IIS 6 box. Thanks for your help
  • 07-20-2009, 5:20 PM In reply to

    • DanielVL
    • Top 75 Contributor
    • Joined on 10-07-2006, 6:00 PM
    • Redmond, WA, USA
    • Posts 109

    Re: Help needed with migrating ISAPI_Rewrite 2.9 rule to IIS7 Url Rewrite

    You can try wildcard matching instead of regex (to simplify it) and then change the matching pattern to something like:

    "product/*/*" where {R:1} would be 66 and {R:2} would be Supplier/Product+Name

    Please note that I removed the leading (the first) slash '/' from the matching pattern, it is not needed.

    Daniel Vasquez Lopez
    URL Rewrite Engine Developer
  • 07-20-2009, 5:41 PM In reply to

    • Xygorf
    • Not Ranked
    • Joined on 07-20-2009, 4:32 PM
    • Posts 5

    Re: Help needed with migrating ISAPI_Rewrite 2.9 rule to IIS7 Url Rewrite

    ooh thats almost there, Thanks for your help... It seems to work ok with product/66/supplier/product but not when there is a + where product name is seperated with + so /product/66/supplier/product+name+name2+name fails any ideas? Thanks
  • 07-20-2009, 6:04 PM In reply to

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

    Re: Help needed with migrating ISAPI_Rewrite 2.9 rule to IIS7 Url Rewrite

    This may fail because of the IIS Request Filtering module blocks requests with "+" symbol in the URL. You can disable that by configuring RequestFiltering module as below:

      <security>
                <requestFiltering allowDoubleEscaping="true" />
      </security>

    http://ruslany.net
  • 07-21-2009, 1:46 PM In reply to

    • Xygorf
    • Not Ranked
    • Joined on 07-20-2009, 4:32 PM
    • Posts 5

    Re: Help needed with migrating ISAPI_Rewrite 2.9 rule to IIS7 Url Rewrite

    Thanks for the update, I'm struggling to find where to add this? How I add this? Thanks for your help with all this.
  • 07-21-2009, 2:00 PM In reply to

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

    Re: Help needed with migrating ISAPI_Rewrite 2.9 rule to IIS7 Url Rewrite

    Open web.config file located at the root folder of your web site. In that file add this XML inside of the <configuration>/<system.webServer> element. The web.config file will looks similar to below:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
      <!-- Some other settings may be here -->
        <security>
          <requestFiltering allowDoubleEscaping="true" />
        </security>
      <!--  Some other settings may be here -->
      </system.webServer>
    </configuration>

    http://ruslany.net
  • 07-21-2009, 2:09 PM In reply to

    • Xygorf
    • Not Ranked
    • Joined on 07-20-2009, 4:32 PM
    • Posts 5

    Re: Help needed with migrating ISAPI_Rewrite 2.9 rule to IIS7 Url Rewrite

    Excellent that has done the job. Thanks everyone for the help.
Page 1 of 1 (9 items)
Microsoft Communities