2012-09-14 18 views
0

我有一個使用經典ASP和HTM/HTML文件完成的舊網站。II7爲(htm | html | asp)重寫規則如果文件不存在,則爲php

現在我要重命名的文件.PHP但保留網址的.asp或.html

www.example.com/some/page.htm到www.example.com/some/page .PHP www.example.com/another_page.asp到www.example.com/another_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> 

但我不知道它是否有效,因爲我必須聯繫我的託管以應用t他改變了我所做的。

回答

0

你的行動標籤更改爲:

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

,你可能要考慮與添加查詢字符串,以及(如果有的話):

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