Solved

Parse PHP from within HTML?

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
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…
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 …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

776 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