0
votes

I am using FileMapProvider to provide dynamic rewrites for a site. This works fine for everything but the homepage where I get the following error:

HTTP Error 403.14 - Forbidden

The Web server is configured to not list the contents of this directory.

I understand why this is. It's because when requesting http://localhost:52709/ the physical path requested is a folder, but really I just want the home page. How can I go about achieving this?

Here's my web.config

<rewrite>
  <rules>
    <rule name="FileMapProvider" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{FileMapProvider:{R:1}}" pattern="(.+)" />
      </conditions>
      <action type="Rewrite" url="{C:1}" />
    </rule>
  </rules>
  <providers>
    <provider name="FileMapProvider" type="FileMapProvider, Microsoft.Web.Iis.Rewrite.Providers, Version=7.1.761.0, Culture=neutral, PublicKeyToken=0545b0627da60a5f">
      <settings>
        <add key="FilePath" value="{DOCUMENT_ROOT}\App_Data\rewriterules.txt" />
        <add key="IgnoreCase" value="1" />
        <add key="Separator" value="," />
      </settings>
    </provider>
  </providers>
</rewrite>

And here is the specific rule in rewriterules.txt

, content/client/site/layouts/home.aspx?menuid=123
1

1 Answers

0
votes

I'm not sure if this is possible to accomplish with the FileMapProvider so in my web.config I just did the following rule:

<rule name="Rewrite Only Root to Virtual Directory" stopProcessing="true">
  <match url="^/?$" />
  <conditions>
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
  </conditions>
  <action type="Rewrite" url="/content/client/site/layouts/home.aspx" />
</rule>