<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<rewrite>
<rules>
<!-- Add the Rewrite with Extra Query at the top -->
<rule name="UserWhere" stopProcessing="true">
<match url="User/([_0-9a-z-(-)-,-.-]+)/([_0-9a-z-(-)-,-.-]+)" />
<action type="Rewrite" url="Main.asp?Type=User&UN={R:1}&Where={R:2}" appendQueryString="true" />
</rule>
<rule name="User" stopProcessing="true">
<match url="User/([_0-9a-z-(-)-,-.-]+)" />
<action type="Rewrite" url="Main.asp?Type=User&UN={R:1}" appendQueryString="true" />
</rule>
<!-- Add the Rewrite With Single Query at the Bottom -->
</rules>
</rewrite>
</system.webServer>
</configuration>
Here, we use the same URL; on the second, we apply a different rule name so that we can reuse the same URL Type=User
Copy
Search Site
Search Google
. We place the Main Rewrite Rule at the bottom of the stack, so it first checks whether there is a reference to the Where Query; if not, it proceeds to the Main Rule and activates it. This keeps it clean and organized, making everything flow much better. Now that I have learned this, I will implement it on our Main site, which will be a nightmare to do since it is already live.