I am in the process of deploying an osCommerce site to a Windows 2008/IIS 7 machine as I write this (no point debating the merit of doing so, you really can’t fight the management if they have taken a decision and you are not even a part of that particular decision making).

So they want a default document of let’s say index.html for their website from where they want to take the user to osCommerce’s main index.php based page. And I need to make the appropriate settings in web.config to have this going.

This should have been easy, IIS 7 supports specifying default documents through web.config and this is what I tried with initially (simply removing index.php from default documents and adding index.html):

 

	<system.webServer>
		<defaultDocument enabled="true">
			<files>
				<remove value="index.php" />
				<add value="index.html" />
			</files>
		</defaultDocument>

Only to be greeted with IIS “500 – Internal Server Error” page asking me to check IIS logs for details. Oh well, I don’t have access to the same and it would be a lot of bureaucratic process to get admin access. What could be the reason.

After some poking around, it struck me that index.html might already have been configured as a default document in machine.config and adding it again here might be causing the Internal server error due to duplicate default documents.

So I tried this and it worked:

 

	<system.webServer>
		<defaultDocument enabled="true">
			<files>
				<remove value="index.php" />
				<remove value="index.html" />
				<add value="index.html" />
			</files>
		</defaultDocument>
	</system.webServer>

Which means if you are trying to configure default documents through web.config, it does not hurt to first <remove /> all documents that you are trying to <add /> to prevent duplicates leading to errors.