Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to configure httpd.conf for parsing html with php 3

Status
Not open for further replies.

tyhand

Programmer
Jul 3, 2002
186
US
Hi all,

I would like for my html pages to be parsed as php.
I've browsed the forums extensively and have concluded
that i'll have to do some changes to the 'httpd.conf' file
OR the 'php.ini' file.

I don't know much about apache and i'm still a newbie
with php.

What changes do i have to make on the httpd.conf file
and where? OR do changes have to be made in the php.ini?

BTW, my server is Apache (Linux(x86)). Thanks all for the
help. Peace!

- tyhand
 
Hey all,

It's me again. I found the following code on my httpd.conf
file. Some of it repeats - don't know why. I list it here
JIC the configuration isn't standard on all servers.

---------BEGIN CODE
# These types cause httpd to let the PHP interpreter handle files with
# the specified extensions.
#

AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml
AddType application/x-httpd-php-source .phps


AddType application/x-httpd-php .php .php4 .php3 .phtml
AddType application/x-httpd-php-source .phps


AddType application/x-httpd-php3 .php3
AddType application/x-httpd-php3-source .phps


AddType application/x-httpd-php .phtml

FURTHER ON DOWN THERE IS THIS:
# To use server-parsed HTML files
#
AddType text/html .shtml
AddHandler server-parsed .shtml .html .htm

----------END CODE

There are other 'AddType' lines but I don't think they
have anything to do with php.

The question still remains. How can i
get my html pages to be read as php?
Thanks again. peace!

- tyhand
 
tyhand,

You don't specify which version of PHP you have installed, or how you installed it, but the first AddType directive should cover it. Leave that line and the line below it, comment out the rest, and restart Apache.

The AddType text/html .shtml line is for SSI, which is independent of PHP.

Wishdiak
A+, Network+, Security+, MCSA: Security 2003
 
Add .html to the first AddType directive and remove the last one (for text/html).
 
Hey garner, wish

Thanks for the reply.

Garner, you say
"Add .html to the first AddType directive and
remove the last one (for text/html)."

So I should add .html to end of this line? -->
AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml

AND remove this one? -->
AddType application/x-httpd-php .phtml
OR is it one? -->
AddType text/html .shtml

Please let me know. Thanks again, Peace!

-tyhand
 
I would think if you want to parse all .html files as php, you could add this line:

AddType application/x-httpd-php .html

This should override the mimetypes where .html is already defined.



 
I hope this teaches me a lesson to read all posts carefully before opening my big mouth. You can either add the new line or add .htm and .html to the end of the existing line as lgarner suggested. You should not have to remove anything though because htm and html are already defined in /etc/mime.types and the AddType directive will override it. If you plan on hosting several sites in the future, doing this in httpd.conf may not be the best way to do this. If you have .htaccess enabled, you can add these lines there where the server can parse them on a per directory basis. Otherwise, every .html file on the server gets parsed as php which may or may not be the disired effect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top