【问题标题】:.htaccess can't parse PHP in HTML files in the root folder.htaccess 无法解析根文件夹中 HTML 文件中的 PHP
【发布时间】:2011-06-12 22:49:17
【问题描述】:

我正在尝试解析 .HTML 文件中的 PHP 代码。

我已将以下代码添加到根文件夹中的 .htaccess 文件中:

...
    <FilesMatch "\.(htm|html|php)$">
      SetHandler application/x-httpd-php5
    </FilesMatch>
...

当我进行此更改时,根文件夹之外的所有文件都可以正常工作。

也就是说,这些 html 文件可以正确解析 PHP,没有任何问题:

  • somedomain/contact/index.html
  • somedomain/about-us/index.html

虽然主页不是:

  • somedomain/index.html

任何帮助将不胜感激。

谢谢。 V

【问题讨论】:

    标签: php html apache parsing .htaccess


    【解决方案1】:

    在开头添加 .* 应该可以解决这个问题

    <FilesMatch ".*\.(htm|html|php)$">
      SetHandler application/x-httpd-php5
    </FilesMatch>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-16
      • 1970-01-01
      • 1970-01-01
      • 2011-04-06
      • 2019-03-03
      • 1970-01-01
      相关资源
      最近更新 更多