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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.