Was trying to avoid URL rewriting as I was hoping there was a simpler way to achieve this using built in functionality, but this turned out to be the easiest way to resolve the issue.
First I had to install the IIS add-in for URL rewriting. This can be done by downloading URL Rewrite from the Microsoft website, or installing it via Web Platform Installer.
Once that was done, I added the following to web.config in my WCF service web application.
<system.webServer>
<!-- Other stuff here -->
<rewrite>
<rules>
<!-- Rewrite requests to /MyService.svc to /v1/MyService.svc -->
<rule name="MyService v1" stopProcessing="true">
<match url="MyService.svc(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="/v1/MyService.svc{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
This allows the v1 service to be accessed via both /MyService.svc
and /v1/MyService.svc
, and v2 can be accessed via /v2/MyService.svc
.