Solved

Parse PHP from within HTML?

Posted on 2006-06-12
4
239 Views
Last Modified: 2010-07-27
Hi experts. I have some html pages that I would like to include a small php snipet that sets a cookie for session id. Everything works fine if I set the file extension to php and use an <include> for the html.
However, I really would prefer to have .html extensions for these pages and not .php.
Is there a way to tell Apache to parse php code within an html page?
I am running Apache 2.0.54 setup on a W2K machine with apache 4.3.11
0
Comment
Question by:formadmirer
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:sleep_furiously
ID: 16890349
Yes, you can add a directive (or modify an existing directive) like:

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

However, be aware that all html pages will be scanned by PHP interpreter, so there could be some performance cost to doing this.
0
 

Author Comment

by:formadmirer
ID: 16890984
Hi and thanks for the reply. I did already try that and everytime I would load the html page my browser would open a box to download the page.
I have tried so many things, including naming the files with shtml so I could use <includes>. Supposedly using this method requires no modification to the server's config file, however it didn't work for me.

I have tried both
AddType application/x-httpd-php .htm .html
and
Addhandler application/x-httpd-php .html .php
but with no luck on either one.
I just can't believe how much trouble I am having getting this to work. Usually I have no trouble at all setting up things on a webserver, but this one is really getting to me.
0
 
LVL 10

Accepted Solution

by:
sleep_furiously earned 250 total points
ID: 16895502
Are you running PHP as CGI or as a module?
0
 

Author Comment

by:formadmirer
ID: 16927788
Hadn't thought about that. I believe on this machine it is running under CGI. Will that make a difference in this situation?
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now