We've had this old rule for years which takes a URL Parameter, parses value server side and renders a final page:
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
<match url="^([^/]+)/?$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="cities.php?id={R:1}" />
</rule>
Now we have a new condition where we want to do something similar but the results and processed URL Parameter need to work differently.
<rule name="RewriteUserFriendlyURL2" stopProcessing="true">
<match url="^([^/]+)/?$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="detail-page-friendly.php?name={R:1}" />
</rule>
The first rule takes the parameter and renders a page using that parameter as a variable. The second rule takes the parameter and creates a result based on a database record. Each uses a different PHP page to create the final page.
Because we are virtually doing the same thing in each case there is a need to figure out how to separate the two rules.
I've considered two different triggers such as making the second rule linked directly such as /pageName.php?name=something Which then rewrites to /something And set this rule first with a "stopProcessing="true" " so as to not move to the older rule which is looking for just a word (Parameter) without a page name. Link from the second case would be /cityName
The thought is that in one case we look for the page name (pageName.php) and then stop looking at further rules. IF that condition is not met we expect the second rule to do its job as it has in the past.
Is this possible ( good logic ) or should I consider some other method?
According to your description, I suggest you could try to use url rewrite condition to achieve your requirement.
If you want to rewrite the url according to different query string, I suggest you could use {querystring} parameter to in your url rewrite rule.
More details, you could refer to below url rewrite rule:
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
<match url="^([^/]+)/?$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{QUERY_STRING}" pattern="name=first" />
</conditions>
<action type="Rewrite" url="cities.php?id={R:1}" />
</rule>
<rule name="RewriteUserFriendlyURL2" stopProcessing="true">
<match url="^([^/]+)/?$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{QUERY_STRING}" pattern="name=second" />
</conditions>
<action type="Rewrite" url="detail-page-friendly.php?name={R:1}" />
</rule>