Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Parse PHP from within HTML?

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

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 This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

856 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