Iis II7如果文件不';不存在

Iis II7如果文件不';不存在,iis,iis-7,rewrite,Iis,Iis 7,Rewrite,我有一个使用经典ASP和HTM/HTML文件的旧网站 现在我想将文件重命名为.php,但将url保留为.asp或.html www.example.com/some/page.htm至www.example.com/some/page.php www.example.com/other_page.asp至www.example.com/other_page.php 等等 我试过这个,灵感来自这里的另一个答案: <rule name="HTML to PHP"> <mat

我有一个使用经典ASP和HTM/HTML文件的旧网站

现在我想将文件重命名为.php,但将url保留为.asp或.html

www.example.com/some/page.htm至www.example.com/some/page.php www.example.com/other_page.asp至www.example.com/other_page.php 等等

我试过这个,灵感来自这里的另一个答案:

<rule name="HTML to PHP">
    <match url="^(.*)\.htm$" ignoreCase="true" />
    <conditions logicalGrouping="MatchAll">
        <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="{R:2}.php" />
</rule>


但我不知道它是否有效,因为我必须联系我的主机以应用我所做的更改。

将您的操作标记更改为:

<action type="Rewrite" url="/{R:1}.php" />

,您可能需要考虑用以下方式添加查询字符串(如果提供的话):


<action type="Rewrite" url="/{R:1}.php" appendQueryString="true" />