iisurl-rewritingurl-rewrite-module

Have Subdirectory of site in IIS show the index.html file when browsing to site


I am a fairly novice windows IIS guy, so any help I would greatly appreciate.

I have a client that requested all root Urls on their department websites redirect to their index.html page. So if a user, for example, goes to https://mysite.domain.com/, it will redirect to https://mysite.doman.com/index.html.

I did this through IIS 10 using a URLrewrite rule on the root of each site by doing the following.

         <rule name="Index Request" enabled="true" stopProcessing="true">
             <match url="^$" />
             <action type="Redirect" url="https://mysite.domain.com/index.html" />
      </rule>

This seemed to work.

The client now wants to have any of the subfolders of the root site show the index.html to any subdirectory sites of the root. Example. Https://mysite.domain.com/subdir/ “This is what shows now” to https://mysite.domain.com/subdir/index.html. Is there a way to do this in IIS?

Thanks in advance for any advice

I have made sure the index.html is the default document. I have also looked at User Friendly URL-template https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/user-friendly-url-rule-template, but I am not sure if this is the right direction to go.


Solution

  • <rule name="SEF Rule" stopProcessing="true">
     <match url="^(.*)$" ignoreCase="false" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}/index.html" matchType="IsFile" 
     ignoreCase="false" />
        </conditions>
        <action type="Redirect" url="{R:1}/index.html" />
         </rule>