开发者

Can't run php code from inside html file

I am having a problem running my php code from inside an html file. I have tried the .htaccess met开发者_Python百科hod and the handler method. I'm using a webserver with cpanel(version 11), apache(2.2.15) and php(5.2.13).I have also tried the files on xampp and they work perfect, but when I upload them to the webserver the php code from inside the html will not run. Any suggestions, please?


You need to inform Apache that files of type 'html' need to be parsed by PHP. You can do this by adding this to the Apache configuration file (httpd.conf):

AddType application/x-httpd-php .html

However if you have other HTML files I would advise just rename the file to PHP (or set up some internal mapping so you don't specify an extension all together). If you have static HTML files that you serve, it's redundant to have them being executed by the PHP interpreter.


Why don't make it a PHP file and then rewrite PHP extension with HTML in .htaccess?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜