开发者

Executing HTML as PHP

开发者 https://www.devze.com 2023-04-02 04:46 出处:网络
When I try to embed PHP into an HTML file, it doesn\'t work. I edited my .htaccess so that it treats HTML file开发者_如何学Gos as PHP, but when I try to visit the .html file my browser downloads it in

When I try to embed PHP into an HTML file, it doesn't work. I edited my .htaccess so that it treats HTML file开发者_如何学Gos as PHP, but when I try to visit the .html file my browser downloads it instead of parsing and displaying it.

EDIT: My .htaccess contents:

AddType application/x-httpd-php .html


Try:

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

EDIT:

Depending on your host, you may need to modify it a bit such as:

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

OR

AddType php5-script .php .html
RemoveHandler .php .html
<FilesMatch "\.(php|html)$">
SetHandler php5-script
</FilesMatch>
0

精彩评论

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