Take the 2-minute tour ×

I have a shared hosting where I have multiple domains and subdomains, and I'm trying to map subdomains to subdirectories such as:

www.mysite.com maps to /sites/mysite physically, www.myanothersite.com maps to /sites/myothersite etc. and I can set this up at GoDaddy's settings. However,

I'd like to map backend.mysite.com to /backend physically (NOT /sites/mysite/backend/) and here is what I've written in web.config in my physical root, /:

    <rule name="backend" stopProcessing="true">
      <match url=".*" />
        <add input="{HTTP_HOST}" pattern="^backend.mysite.com$" />
        <add input="{PATH_INFO}" pattern="backend/" negate="true" />
      <action type="Rewrite" url="\backend\{R:0}" />

It actually DOES work, but when I enter http://backend.mysite.com IIS actually thinks that I'm browsing a same-name subdirectory under backend.mysite.com and behaves as I'm on backend.mysite.com/backend. All the applications/links etc. does work, but I don't want such a path in my URLs. Such as, when I'm directory browsing, all the files under http://backend.mysite.com appear as links to http://backend.mysite.com/backend/file1.txt etc. (notice the extra backend in the path). I also have a similar rule for apps, and for example, when I go to http://apps.mysite.com/myapp, I am redirected to http://apps.mysite.com/apps/myapp. It works, the site opens and runs perfectly, but I don't want that extra path. More weirdly, if I explicitly remove that path after opening the site and write http://apps.mysite.com/myapp (yes, just as I've written before), then my site DOES open at my desired path, http://apps/mysite.com/myapp, without redirection. These rules have long been in my web.config and I didn't really have the time to investigate, and I don't actually remember where I got these from. I'm not a regex master, nor an ASP.NET Rewriting master, so could someone correct what is wrong at my rules? Thanks, Can.

share|improve this question
add comment

Your Answer



Browse other questions tagged or ask your own question.