url-rewritingtuckey-urlrewrite-filter

How Can I Create a Tuckey Passthrough Rewrite Rule for Just the Root of a Folder that Already Exists on the Filesystem?


I'd like to create a Tuckey rewrite rule that matches only when the URL points to the root of a particular subfolder like this: http://localhost/foo (or http://localhost/foo/)

In this scenario, the /foo folder already exists and I need to make sure static assets under the /foo folder can still be accessible as normal. For example "http://localhost/foo/img/flower.jpg".

Here's what I've come up with so far, but it isn't working:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN" "http://tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite>
    <!-- Turn foo/ into /index.cfm/foo/ -->
    <rule>
        <from>^/foo$</from>
        <to type="passthrough">/index.cfm/foo</to>
    </rule>
</urlrewrite>

I suspect I may need to make some tweaks to the regex in the <from> section. Any help you could offer would be most appreciated!


Solution

  • This should do the trick:

    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN" "http://tuckey.org/res/dtds/urlrewrite4.0.dtd">
    <urlrewrite>
        <!-- Turn foo/ into /index.cfm/foo/ -->
        <rule>
            <from>^/foo/$</from>
            <to type="passthrough">/index.cfm/foo</to>
        </rule>
    </urlrewrite>
    

    You have to add a slash before the $. This should execute the rule for the following paths:

    It will ignore the following paths: