PHP in HTML files not running or being commented out

天涯浪子 提交于 2019-12-12 03:34:41

问题


First of all, I am not trying to run php within a js script, there is a similar question on here that refers to a user trying to run php from inside a js script.

I have added many combinations of

AddType application/x-httpd-php .php .html

AddHandler x-httpd-php .html

to the .htaccess file in a higher level directory containing the .html file I want to run php in. This has not worked. (I am open to trying new combinations)

The is either not read at all or commented out when viewing the source in broswer.

My question is how to get to be run inside of an html file OR is there a better way to include php functionality in an html document without having the code in the same document.

Additionally my host uses cpanel if this helps anything.

I can elaborate on anything I need to, thanks in advance.


回答1:


You can try to use mod_rewrite for that task:

RewriteEngine On
RewriteRule ^(.*).html index.php [QSA]


来源:https://stackoverflow.com/questions/14926372/php-in-html-files-not-running-or-being-commented-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!