Forum Moderators: phranque
Part of my trouble may be that I am using MS FrontPage which puts some of its own stuff into the .htaccess and it has been quite some time since I undertook to understand just how FP uses .htaccess.
Here is my test page code.
=================
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<body>
Hi Mom
<p>
<?php
phpinfo();
?>
</p>
<p>Hi Dad</p>
<p> </p>
</body>
</html>
=====================
First I tried changing my httpd.conf by adding .htm to the AddType code:
=================
<IfModule mod_php4.c>
AddType application/x-httpd-php .php .php4 .php3 .phtml
AddType application/x-httpd-php-source .phps
==Like this ================
<IfModule mod_php4.c>
AddType application/x-httpd-php .php .php4 .php3 .phtml .htm
AddType application/x-httpd-php-source .phps
===================
The result is that, if and only if the .htm page contains php code, instead of parsing the php code. The entire page is downloaded to a temporary file and the temporary file opens in a new window as html, ignoring the php as comments.
I took the code out of the httpd.conf file and put it into the .htaccess
AddType application/x-httpd-php .htm
with exactly the same result, the page downloads and opens in a new window as html ignoring the php as a comment.
For reference, here is my .htaccess file:
======================
# -FrontPage-
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
AddType application/x-httpd-php .htm
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.myservername.com
AuthUserFile /var/www/html/_vti_pvt/service.pwd
AuthGroupFile /var/www/html/_vti_pvt/service.grp
===========================
Let me say also that pages named .php work just fine as do those named .htm which contain no php code.
As it is 05:00 hours, I am going to bed, with hope that someone will point out my error.
Welcome to WebmasterWorld!
It looks to me as if you've got AddType [httpd.apache.org] and AddHandler [httpd.apache.org] confused.
Rather than declaring that the MIME-type of your htm files should be application/x-http-php by using AddType, you'd be better off telling the server to parse htm files for php includes using AddHandler:
AddHandler server-parsed .htm
Also, using .htaccess with FrontPage extensions [webmasterworld.com] causes a major headache, in that you will probably have to hunt down every .htaccess file in every FrontPage extension-related directory on your site, and change Options None to Options +FollowSymLinks in each of those .htaccess files whenever you "publish" a new version of the site.
Jim
Fixing this in .htaccess in a side directory is easier. Once that works, transferring the fix to conf is the second set of problems. Problems usually saved for late at night.
All that aside, I tried the
=========
AddHandler server-parsed .htm
=========
statement, the server did not parse the php but simply returned it as comments in the html.
Re-searching the forums, I have tried adding
=========
AddType text/html .htm
AddHandler server-parsed .htm
==========
And I have tried
===========
Options +Includes
AddType text/html .htm
AddHandler server-parsed .htm
===========
none of these had any effect.
I am confused by one thing here, how does the server know with what to parse this code, nothing here tells the server to look for php code as opposed to say ssl or perl?
My server runs php as a cgi, is that a problem?
Are you on Apache 1 or 2?
If on Apache 1.x, make sure that PHP appears *before* mod_rewrite in the LoadModule list. Modules are invoked in reverse order to that shown in the LoadModule list. Therefore, if PHP appears *after* mod_rewrite in the LoadModule list, it will run *before* any mod_rewrite code can be processed and have any effect.
Jim
In reviewing this problem, I cleared all the changes that I have made.
I went back to the httpd.conf and made this one change to create a page type .zxz.
===============
<IfModule mod_php4.c>
AddType application/x-httpd-php .php .php4 .php3 .phtml .zxz
AddType application/x-httpd-php-source .phps
</IfModule>
=================
The test page renamed to test.zxz worked just fine.
This tells me that there is something inhibiting the parsing of .htm pages.
Any Ideas?
Prior to adding .html .htm to the statement
===============
<IfModule mod_php4.c>
AddType application/x-httpd-php .php .php4 .php3 .phtml .htm .html
AddType application/x-httpd-php-source .phps
</IfModule>
================
This conflict apparently caused .htm & .html to be doubly assigned.