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:
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.
2

#2 User is offline   jacmoe 

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

Posted 16 February 2016 - 09:57 PM

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

#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:
0

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