Parsing HTML files as PHP

后端 未结 3 1097
旧时难觅i
旧时难觅i 2020-11-30 15:35

Is this the correct way to parse html files as php?

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

Saved in a .ht

3条回答
  •  一向
    一向 (楼主)
    2020-11-30 16:02

    In my case, I wanted to parse HTML files as PHP so I added the code you mentioned on my .htaccess which is:

    AddType application/x-httpd-php .html

    It worked on my localhost as intended since I'm using WAMP but on my server, which is hosted in Drupion this does not work. My HTML files became downloadable.

    The answer here gave me an idea on how to fix the problem.

    Basically, you need to know the "handler-name" your server is using to parse PHP. Then you can add similar code on your .htaccess.

    AddHandler fcgid-script .html
    FCGIWrapper /home/example/fcgi-bin/php5.fcgi .html
    

提交回复
热议问题