Redirect all requests to a default document to its parent directory instead. This is an important SEO tactic to avoid duplicate content penalties due to both /directoryname/ and /directoryname/index.php both returning the same document response. This redirect should be Permanent (301).
To redirect all requests to one or more default documents to the parent directory url, add the following rule to web.config’s <rules> section:
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect default doc to parent directory" stopProcessing="true">
<match url="^(.*)(index.php|default.php)" ignoreCase="true" />
<action type="Redirect" url="https://www.example.com/{R:2}" redirectType="Permanent" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
This would cause all requests to index.php or default.php anywhere in the site’s URL hierarchy to be redirected to the parent directory’s URL. For example, a request to /articles/index.php would be redirected to /articles/.
Change (index.php|default.php) to your own website/language’s default document(s). Separate multiple entries with the pipe | symbol.