Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hopefully this all makes sense:

I have a Web Application project against an IIS7 server that is "theme-able" using different master pages.

As a result of what I am trying to do, the root of the project has no aspx files, so I am using the web.config's ability to rewrite "~/default.aspx" to "~/themes/a/default.aspx"

this works great as long as i type in "", but typing just "" results in a "403 - Forbidden: Access is denied" error

I was hoping that the combination of urlMapping and default document would be smart enough to handle this, but it's not

      <defaultDocument enabled="true">
              <clear />
              <add value="default.aspx"/>

i also tried

      <defaultDocument enabled="true">
              <clear />
              <add value="~/themes/a/default.aspx"/>

to no avail

I was hoping a browser would come in without a document defined, IIS7 would assume it was default.aspx, and then the urlMapping would map it accordingly, but nope

any pointers? I've read a ton of posts here with similar issues, but not the exact issue

share|improve this question

You can handle both scenario's of and with one single URL rewrite rule.

<rule name="Rewrite to theme folder">
    <match url=".*" />
    <conditions logicalGrouping="MatchAny">
        <add input="{URL}" pattern="^/default\.aspx$" />
        <add input="{URL}" pattern="^/$" />
    <action type="Rewrite" url="/themes/a/default.aspx" logRewrittenUrl="true" />

The default document can only be set to file name. You can't specify a folder. IIS will probably ignore your entry as it can't open it as a file. The 403 error is occurring because there is probably no other default document specified (or found) and directory browsing is disabled (by default).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.