I am migrating many sites from an aging IIS5 server to a new IIS7.5 server. Many of the sites utilize extensionless file names, and PORT80 “PageXchanger” was used to negotiate the file names. (for those not familiar, PageXchanger was an IIS solution for Apache’s “MultiViews”)
Well - PORT80 has discountinued that product, and the latest version is not compatible with IIS7, so I either re-write 100 websites, or create a solution!
I am looking at using the IIS7 Rewrite Module, and for the most part, I have made this work.
<rewrite>
<rules>
<rule name="PHP">
<match url="^(.*)$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:0}.php" />
</rule>
</rules>
</rewrite>
In the end - if I type “www.site.com/test”, the page fetched is “test.php”. I have tested this and it works regardless of the depth of directories which is what I need.
This is great for hiding PHP extensions only, but I want the rewrite to look for a few extensions (ie: .html, .php, .htm). If .html doesn’t exists, look for .php. If that doesn’t exist, look for .htm. If that doesn’t exist - give up and throw a 404.
I know the answer is in this line “<action type=“Rewrite” url=”{R:0}.php" />" but I am not sure what to replace “.php” with to make it work.
Any ideas or suggestions?