Solved

Parse PHP from within HTML?

Posted on 2006-06-12
4
228 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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

757 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

17 Experts available now in Live!

Get 1:1 Help Now