在 Apache 服务器上处理特定的.htm页面作为.php


Process specific .htm page as .php on Apache server

我正在为Apache服务器编程,我只需要一个特定的html页面(比如,first.htm)作为PHP脚本进行处理。可以设置吗?

也可以

使用SetHandler指令:

强制处理程序处理所有匹配的文件

当放入 .htaccess 文件或 部分,此指令强制解析所有匹配的文件 由处理程序名称给出的处理程序。

<Files first.htm>
    SetHandler application/x-httpd-php
</Files>

创建一个名为 .htaccess 的文件,并将其放在该文件所在的目录中。将此行添加到 ti:

<Files first.htm>
    AddType application/x-httpd-php .htm
</Files>
<Files first.htm>
    ForceType application/x-httpd-php
</Files>