« Previous Next »

Thread: Seek Professional Help!!!

Last post 05-11-2009 1:17 PM by ruslany. 1 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (2 items)

Sort Posts:

  • 05-11-2009, 9:30 AM

    Seek Professional Help!!!

    I need professional help here... Here's the situation... I have product URL's going to detail pages.  On that page it breaks out into sub-sections, at times it also carries extra parameters in the query string other than "v" and "fa"... note that "v" is an alpha-numeric product ID, and "fa" is the sub-section

    • res/stat.cfm?v=id (default page)
    • res/stat.cfm?v=id&fa=graphs
    • res/stat.cfm?v=id&fa=comments
    • res/stat.cfm?v=id&fa=whatever

    I'm looking to create rule(s) like the following:

    • alphanumericID
    • alphanumericID/graphs
    • alphanumericID/comments
    • alphanumericID/whatever

    I'm thinking the second parameter after the ID needs to be written as some kind of wildcard so that it will work in any of the above examples?? 

    I'm also looking for these rule requirements:

    • no hardcoded rule values (ex: graphs, comments, etc) as they get changed at times.
    • make sure the alphanumericID is just that (regex A-Z 0-9), if not, skip rule
    • direct access to "res/stat.cfm" forces a "url has moved" host headers then redirects to the rewritten version.
    • It would also be nice to be able to access the "res/stat.cfm" directly for testing and development purposes and bypass the redirect... (ex: res/stat.cfm?id=abc123&bypass=1)

    Here's what I have so far which is not flexible and error prone.....

    Pattern: ^([^/]+)/?$

    Rewrite URL: res/stat.cfm?v={R:1}

    Clearly this doesn't do what I need it to do and far from flexible... I've been banging my head against the wall trying different things with minimal success. I know there's someone out there that could probably write this up in 2 minutes!

    I'd greatly appreciate the help!  Thanks big time in advance!

    By the way, the site in question is... http://www.cbengine.com


     

  • 05-11-2009, 1:17 PM In reply to

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

    Re: Seek Professional Help!!!

    You can start from something like below and then tweak it further:

    <rules>
                    <rule name="Redirect requests for cfm" stopProcessing="true">
                        <match url="^res/stat\.cfm$" />
                        <conditions>
                            <add input="{QUERY_STRING}" negate="true" pattern="bypass=1" />
                            <add input="{QUERY_STRING}" pattern="v=([\d\w]+)&amp;fa=([\d\w]+)" />
                        </conditions>
                        <action type="Redirect" url="{C:1}/{C:2}" />
                    </rule>
                    <rule name="Rewrite to cfm">
                        <match url="([\d\w]+)/([\d\w]+)" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="res/stat.cfm?v={R:1}&amp;fa={R:2}" appendQueryString="false" />
                    </rule>
                </rules>

    The first rule will redirect all requests that came to res/stat.cfm?v=id&fa=something to /id/something. If the request contained a parameter bypass=1 then no redirection will be done. The second rule will rewrite all requests to /id/something to res/stat.cfm?v=id&fa=something. The extra conditions there are necessary to prevent rewriting of requests for statis files (e.g. css, js, images).

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