Difference between #2 and #3 of How to hide index.php on Microsoft Windows Server with IIS7

unchanged
Title
How to hide index.php on Microsoft Windows Server with IIS7
unchanged
Category
How-tos
unchanged
Tags
Widgets, iis7, hide index.php, scriptname
changed
Content
I've seen lot of people struggling in finding a way to hide the script name when
installing their Yii Application. In an Apache environment everything is well
documented in [this wiki
article](http://www.yiiframework.com/wiki/214/url-hide-index-php/ ""),
but for those who are running their app on a Windows Server machine there are no
hints.

IIS 7.0 introduces a native URL rewriting module, and it can be configured as
you want simply creating a web.config file (that is a simple xml file) and
putting it on the root level folder.

Basically what follows is a simple translation of the classic .htaccess file
used in LAMP environment. 

The old .htaccess file:

~~~
[php]
RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php
~~~

Now become web.config:

~~~
[xml]
<?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>
		
</system.webServer>	
</configuration>
~~~

Just place this file in your root folder and everything should work like a
charm, obviously you still need that your urlManager component must have its
"showScriptName" param set to false.

~~~
[php]
'urlManager'=>array(
    'urlFormat'=>'path',
    'showScriptName'=>false,
     'caseSensitive'=>false,        
),
~~~

This feature has been succesfully tested on Windows Azure Web Sites.