I have a website in IIS, with a legacy classic asp application configured as a sub app.
I'm basically trying to create URL rewrite rules so that I don't have to change all of the relative URL's in the code.
e.g. URLS's such as "/themes/somedirectory" should be mapped to "/legacy/themes/somedirectory"
Using the URL Rewrite Module 2.0 I have a URL rewrite rule configured as follows:
<rule name="Reroute themes">
<match url="^themes.*" />
<action type="Rewrite" url="/legacy/{R:0}" />
</rule>
This works fine when navigating to the URL. However when using Server.MapPath()
, it is not applying the rewrite rule.
Is Server.MapPath()
actually supposed to take this into account? If not, how should I go about re-routing the application without modifying the code?
I just had this problem, and for now am going with create a special MapPath variant that corresponds to my rewrite rule.
So either something like this:
Or, if you prefer:
Or generalize:
I don't especially like this, because it violates "do not repeat yourself".