请注意,这仅适用于 IIS7而不适用于 IIS6。这也需要设置 FastCGI并安装和启用URL 重写模块。这些是您的托管人能够为您验证的内容。如果以上所有情况都成立,那么以下文件应该可以解决问题(您可能需要调整路径,但我认为如果您向主机提供此示例文件,您的主机将能够为您执行此操作。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<sectionGroup name="system.webServer">
<sectionGroup name="rewrite">
<section name="rewriteMaps" overrideModeDefault="Allow" />
<section name="rules" overrideModeDefault="Allow" />
</sectionGroup>
</sectionGroup>
</configSections>
<system.webServer>
<!-- Mapping the .do extension to the PHP ISAPI module -->
<handlers>
<!-- the following line is very specific to your host
please check the module name and the scriptProcessor
path with the system administrator! basically this is
the same as
http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis-70/#EnableFastCGI
only in .config format. -->
<add name="MaskDoAsPHP" path=".do" verb="GET,HEAD,POST,DEBUG" modules="FastCgiModule" scriptProcessor="C:\PHP\php-cgi.exe" />
</handlers>
<!-- Setting the default handler. -->
<defaultDocument>
<files>
<clear />
<add value="home.do" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="Removing do extension" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<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="{R1}.do" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>