URL 中的 IIS php 扩展
IIS php extension in URL
我正在将 Apache 服务器迁移到 IIS 服务器。
目前,在 Apache 服务器 中,如果我们有一个名为 www.example 的 PHP 页面。com/test.php,即使没有最后的“.php”(即www.example,我们也可以访问它。 com/test).
如何在 IIS 中实现类似的行为?
使用 IIS8 及更高版本,Microsoft 实现了 Web 平台,您可以从那里下载模块 URL Rewrite(或者直接从 their site 下载)。
之后,转到 IIS 服务管理并单击 "URL Rewrite"
在右侧面板中,您会看到 "Import rules.."
的选项
选择您的 .htaccess
(您目前在 public_html
上)并点击 "Import" 按钮。
这会在您的站点路径中创建一个名为 web.config
的文件,其内容如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect index.php" stopProcessing="true">
<match url="index\.php/(.*)" />
<action type="Redirect" url="{R:1}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
还有一些在线服务可以将您的 .htaccess
转换为 web.config
,尽管我已经尝试了一些并且从 IIS 服务管理导入效果更好。
我正在将 Apache 服务器迁移到 IIS 服务器。
目前,在 Apache 服务器 中,如果我们有一个名为 www.example 的 PHP 页面。com/test.php,即使没有最后的“.php”(即www.example,我们也可以访问它。 com/test).
如何在 IIS 中实现类似的行为?
使用 IIS8 及更高版本,Microsoft 实现了 Web 平台,您可以从那里下载模块 URL Rewrite(或者直接从 their site 下载)。
之后,转到 IIS 服务管理并单击 "URL Rewrite"
在右侧面板中,您会看到 "Import rules.."
的选项选择您的 .htaccess
(您目前在 public_html
上)并点击 "Import" 按钮。
这会在您的站点路径中创建一个名为 web.config
的文件,其内容如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect index.php" stopProcessing="true">
<match url="index\.php/(.*)" />
<action type="Redirect" url="{R:1}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
还有一些在线服务可以将您的 .htaccess
转换为 web.config
,尽管我已经尝试了一些并且从 IIS 服务管理导入效果更好。