Hi Karim Darbeida,
Here are a few things that might be causing the issue:
URL Pattern Matching
Your rule uses:
<match url="^/tfs/(.*)" />
However, IIS URL Rewrite does not include the leading slash (/) in the url pattern. This means the rule won’t match as expected, so it should be:
<match url="^tfs/(.*)" />
The rule Order and Precedence
Your first rule (Forward root) matches everything (.*) and rewrites it to http://sptfs2:81. Since it comes before the more specific /tfs/ rule, it may be intercepting all requests — including those meant for /tfs.
You can move the /tfs/ rule above the root rule or set stopProcessing="true" on the root rule only if you want it to short-circuit.
Preserving the Subfolder Path
Your current rewrite action for /tfs/ does not preserve the subfolder path. It rewrites everything to http://sptfs2:81, which likely breaks routing.
You can try:
<action type="Rewrite" url="http://sptfs2:81/tfs/{R:1}" appendQueryString="true" />
This ensures that /tfs/some/path is rewritten to http://sptfs2:81/tfs/some/path.
TFS-Specific Configuration
If the above changes don’t help, it’s possible that TFS has its own web.config or HTTP modules that are interfering with the rewrite. You might want to check if there’s a web.config under the tfs folder or if TFS is using its own routing logic.
Let me know if applying these changes helps resolve the issue.