Even if there are tutorials and topics about hiding index.php, I failed to achieve that by following those steps.
And most of the tutorials are all based on Apache not IIS.
This is my first post and I am writing here to show how to hide index.php on IIS7. This solution works perfectly for me:
CONFIG:WIN 7
IIS7
YII2
STEP1:
Make sure you have installed URL Rewrite on your IIS7. That means you can find this tool on the home page when you open your IIS7 manager.
STEP2:
Create a web.config file under \frontend\web or \backend\web or other directory under your need.
web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<rewrite>
<rules>
<rule name="Hide Yii Index" stopProcessing="true">
<match url="." ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
<modules runAllManagedModulesForAllRequests="true" >
<remove name="UrlRoutingModule"/>
</modules>
</system.webServer>
</configuration>
STEP3:
Make your urlManager as the following.
‘urlManager’ => [
'class' => 'yii\web\UrlManager',
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => false,
]
Then, it will make your url clear without index.php in the middle of it.
Remember, do not do anything else or you will not get the server run successfully. Eg, do not put web.config under other folder such as root level folder as other tutorial said.
All these works for me. Hope this helps. Thanks for reading.