Jump to content

PHPinfo in html


TwiztedCupid

Recommended Posts

Hello,
Yes I'm pretty much a n00b when it comes to PHP and Apache. I have the server all setup, php installed, PHP modules all setup in httpd.conf. I can run .php files with no problem. The one thing I'm not getting to work is [code]<?php phpinfo();?>[/code] It works when I save the file as test.php, but not when I save it as test.html, or test.htm. It just shows up as a blank page. I viewed the source and the code is still there. When I upload either htm file to another server, the phpinfo function works fine. I need to know if there's something in Apache or PHP that I have to configure to let this run properly on my machine.

I'm using Apache 2.2.3 and PHP 5.2.
Link to comment
https://forums.phpfreaks.com/topic/31660-phpinfo-in-html/
Share on other sites

If you want htm(l) files to parse PHP code then you will need to the server that. You can do that by adding .htm and/or .html to the end of the list for the following line in the httpd.conf:
[code]AddType application/x-httpd-php .php[/code]

Like so:
[code]AddType application/x-httpd-php .php .htm .html[/code]

Save the httpd.conf and restart Apache. PHP code will now be executable in .htm and .html files
Link to comment
https://forums.phpfreaks.com/topic/31660-phpinfo-in-html/#findComment-146883
Share on other sites

  • 2 weeks later...
Or if you use .htaccess files you can just use the ForceType directive...

Create a .htaccess file in the same directory as the file you want to call "test.html"... Add this to the .htaccess file...

<FilesMatch "test.html">
  ForceType application/x-httpd-php
</FilesMatch>


Hope this helps!  ;D
Link to comment
https://forums.phpfreaks.com/topic/31660-phpinfo-in-html/#findComment-152488
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.