1
Options +Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.html$ $1.php [L]

Is what i would use in Apache mod rewite to make it so index.html is actually index.php

How can i do this in IIS ?

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="false" />
        <defaultDocument>
            <files>
                <clear />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="Default.aspx" />
                <add value="index.html" />
                <add value="index.php" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

This is what i have for my current config. Thanks in advance.

1
  • Why is this tagged with iis6?
    – user156643
    Jun 17, 2013 at 14:27

1 Answer 1

3

If you have access to IIS7's management console on the host or any machine that is running IIS7 and UrlRewrite then you can automate the conversions.

First of all, copy your mod_rewrite rules to a file and save as something like mod_rw.htaccess.

Launch IIS7's management console, navigate to your site. Launch the UrlRewrite feature:

enter image description here

On the right hand Actions Pane select Import Rules:

enter image description here

Click on the elipses button next to the Configuration File text box, locate and select mod_rw.htaccess:

enter image description here

Next click the Import button:

enter image description here

Upon clicking Import, your mod_rewrite rules will be imported and converted to IIS7's UrlRewrite 2.0 rule format.

Your can view the raw XML configuration by clicking on the XML View tab:

enter image description here

At this point, if you click on the Back to Rules link in the right hand action pane menu, the importer will ask if you want to save these rules. If this isn't the intended target machine then just copy what's in the Xml View tab and paste in the web.config belonging to the target site.

On a final note (and you may already know this), you can actually change the default document order so that index.php is preferred over index.html:

<defaultDocument>
    <files>
        <clear />
        <add value="index.php" /> <!-- <-- moved to top of list -->
        <add value="Default.htm" />
        <add value="Default.asp" />
        <add value="index.htm" />
        <add value="Default.aspx" />
        <add value="index.html" />
    </files>
</defaultDocument>

You must log in to answer this question.