Forum Moderators: coopster

Message Too Old, No Replies

php won't work in html file

.htaccess file setup too

         

gford

1:10 pm on May 13, 2005 (gmt 0)

10+ Year Member



I can't get php code to work in html files.

Here is my .htaccess file:

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

it doesn't parse the php part, source code looks like:
<html>
<body>
<?php
echo 'test';
?>
</body>
</html>

I have turned off SSI - made no difference.

Any help is appreciated on this. Thanks. I am completely and utterly stumped and have read many php html posts.

[edited by: jatar_k at 3:33 pm (utc) on May 13, 2005]
[edit reason] no urls thanks [/edit]

StupidScript

4:43 pm on May 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How is your httpd.conf file set up to handle PHP?

In addition to specifying the type, PHP needs to be either compiled into Apache or included in the conf file as a module.

Here's what's in my httpd.conf file:

LoadModule php4_module libexec/libphp4.so

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

gford

7:46 pm on May 13, 2005 (gmt 0)

10+ Year Member



Hello,

I just did a grep of my conf file and no mention AT ALL of php.

Should I try adding your two lines?

Does it matter where in the .conf to add it? Kind of new to that part of apache.

gford

7:55 pm on May 13, 2005 (gmt 0)

10+ Year Member



OK. I added your things, then when I did this it tries to open/save the .shtml file to local disk.

Is this related to SSI issues?

Also - it doesn't appear my .htaccess file is being read.

I can type junk in there and see no error?

mcibor

8:39 pm on May 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there any file extension that is being parsed?

Can you parse the .php files? If not, then you haven't installed php properly, if yes, then the AddType should be enough.

Write if you can parse .php.
Best regards
Michal Cibor

StupidScript

8:53 pm on May 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mcibor is right ... sounds like you do not have PHP installed properly, if at all.

Are you running a Win server, or Linux or what?

When you do get it up and running, the necessary lines will have been added to your conf file, and you'll want to edit the conf file to add

.html
and
.shtml
to the PHP AddType line, save the conf file and restart your server to get them in there.

BTW, in a Win installation you'll be using a .DLL or .EXE file instead of the .SO (shared object) file:

LoadModule php4_module c:/Apache/php/sapi/php4apache.dll

Check out this informative page [webmasterstop.com] to figure out what you need to do with a Win installation.

For my own Linux installations, I have chosen to compile PHP support into the Apache daemon binary file, which is a whole 'nother thing. ;)

gford

12:49 pm on May 14, 2005 (gmt 0)

10+ Year Member



PHP runs fine as my test url shows:
www.example.com/test.php

also - I run 6 mambo sites on this (all php/mysql based only sites) server.

[edited by: jatar_k at 3:29 pm (utc) on May 14, 2005]
[edit reason] no personal urls thanks [/edit]

gford

12:50 pm on May 14, 2005 (gmt 0)

10+ Year Member



I run RedHat Linux