.htaccess can't parse PHP in HTML files in the

2019-06-13 20:15发布

I'm trying to parse PHP code inside .HTML files.

I have added the following code to the .htaccess file in the root folder:

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

All the files outside the root folder are working fine when I made this change.

That is, these html files are parsing the PHP correctly without any issues:

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

While the homepage is not:

  • somedomain/index.html

Any help will be greatly appreciated.

Thx. V

1条回答
Rolldiameter
2楼-- · 2019-06-13 20:20

Adding .* at the start should solve this issue

<FilesMatch ".*\.(htm|html|php)$">
  SetHandler application/x-httpd-php5
</FilesMatch>
查看更多
登录 后发表回答