IIS remove index.php

iis

Below are my web.config, my problem is when access the www.domain.com it will forward to www.domain.com/index.php but some will stay on www.domain.com (without the index.php)

How do I ensure even user access using index.php it will redirect to / ?

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="true" />
        <defaultDocument>
            <files>
                <clear />
        <add value="index.php" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="Default.aspx" />
            </files>
        </defaultDocument>
        <httpErrors>
            <remove statusCode="403" subStatusCode="-1" />
            <error statusCode="403" prefixLanguageFilePath="" path="https://www.domain.com" responseMode="Redirect" />
        </httpErrors>
    </system.webServer>
</configuration>

Best Answer

If you want your index document rewritten to the base of the path in the URI, do the following:

  1. Install the URL Rewrite Module 2.0 for IIS
  2. Use the following rule to accomplish your rewrites:

-

<rule name="Default document rewrite" stopProcessing="true">
  <match url="(.*)index.php" />
  <action type="Redirect" url="{R:1}" redirectType="Permanent" />
</rule>