Yii Framework Forum: My way to hide index.php on IIS 7 - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

My way to hide index.php on IIS 7 Rate Topic: -----

#1 User is offline   fallie 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 16-February 16

Posted 16 February 2016 - 09:25 PM

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:


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.

Create a web.config file under \frontend\web or \backend\web or other directory under your need.


<?xml version="1.0" encoding="UTF-8"?>
<directoryBrowse enabled="false" />
        <rule name="Hide Yii Index" stopProcessing="true">
            <match url="." ignoreCase="false" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                <action type="Rewrite" url="index.php" appendQueryString="true" />
 <modules runAllManagedModulesForAllRequests="true" >
      <remove name="UrlRoutingModule"/>    


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.

#2 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 3,710
  • Joined: 10-October 10
  • Location:Denmark

Posted 16 February 2016 - 09:57 PM

/* Moved to Tips, Snippets and Tutorials */
"Less noise - more signal"

#3 User is offline   tonton 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 25-April 17

  Posted 10 May 2017 - 01:11 PM

Hi Fallie,
It works, thanks :) :rolleyes:

Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users