'Url rewriting the same number of directory hops with web.config

I have two different databases generating pages for 1. USA/Canada, and 2. UK. The columns are incredibly different so I opted to make two completely different pages dedicated to each database, with the URL structure staying as:

example.com/testing-station/us/ca/los-angeles

and

example.com/testing-station/uk/lincolnshire/lincoln

However, my UK variation (which I'm using in a /uk/ folder) is returning a 404. I assume this is because the two rules are conflicting each other... but nothing I've tried (for example finding a /uk/ pattern and ignoring it on the first rule) is working.

Here is my code.

<rule name="townRewrite">
    <match url="^testing-stations/([^/]+)/([^/]+)/([^/]+)?$" />
    <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_URI}" pattern="\.js|\.css|\.img|\.uk" negate="true" />
    </conditions>
    <action type="Rewrite" url="/testing-stations/america.aspx?c={R:1}&amp;r={R:2}&amp;t={R:3}" appendQueryString="false" />
</rule>

<rule name="UKtownRewrite">
    <match url="^testing-stations/uk/([^/]+)/([^/]+)?$" />
    <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_URI}" pattern="\.js|\.css|\.img" negate="true" />
    </conditions>
    <action type="Rewrite" url="/testing-stations/uk/Default.aspx?r={R:1}&amp;t={R:2}" appendQueryString="false" />
</rule>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source