Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 "http://www.mysite.com/default.aspx", but typing just "http://www.mysite.com" 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

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

i also tried

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

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

1 Answer 1

You can handle both scenario's of http://www.mysite.com/ and http://www.mysite.com/default.aspx 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="^/$" />
    </conditions>
    <action type="Rewrite" url="/themes/a/default.aspx" logRewrittenUrl="true" />
</rule>

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

 
discard

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.