954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP inside HTML files

is there a way to make .html files process php tags?

elamigosam
Light Poster
31 posts since Jun 2009
Reputation Points: 10
Solved Threads: 2
 

Search the forums for AddHandler

ShawnCplus
Code Monkey
Team Colleague
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
 

Thanks.

elamigosam
Light Poster
31 posts since Jun 2009
Reputation Points: 10
Solved Threads: 2
 

I tried search the forums for AddHandler but I cannot come across the solution...

Can you link it?

Thanks,

locobans
Newbie Poster
4 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 
pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

Add this to an .htaccess file in the directory...
(or apache.conf).
(This is for .html files being parsed by php)

AddHandler application/x-httpd-php .html

for .htm files

AddHandler application/x-httpd-php .htm
codejoust
Junior Poster
180 posts since Jul 2009
Reputation Points: 18
Solved Threads: 21
 

Ok thanks for the link...

I have added

AddHandler application/x-httpd-php .html


to my .htaccess file...

Now here's the problem... I have installed what is called a php gallery named MG2 which can be accessed by clicking here http://www.elitedvservices.com/mg2/index.php

Now on the website I'm trying to add a code so that it includes that file...basiclly just trying keep up the same layout and just showin the gallery...if you click this link you'll see that its trying to install the gallery again but yet the gallery is already installed....hosting @ hostamina

http://www.elitedvservices.com/index_1col_top2.html

Here's how I have the code...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Elite D&V Services Inc - 25 Years Experience</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="style/style_1col_top.css" />
<link rel="stylesheet" type="text/css" href="style/colour.css" />
<style type="text/css">
<!--
.style1 {font-size: 200%}
-->
</style>
</head>
<body>
<div id="main">
  <div id="logo">
    <h1>&nbsp;</h1>
  </div>
  <div id="menubar">
    <ul id="menu">
      <li><a class="current" href="index.html">Home</a></li>
      <li><a href="index_2col_right.html">Events</a></li>
      <li><a href="index_1col_bottom.html">About Us </a></li>
      <li><a href="index_1col_top.html">Contact Us </a></li>
	  <li><a href="index_1col_top2.html">Pictures </a></li>
    </ul>
    <div id="search">
    </div>
  </div>
  <div id="site_content">
    <div id="content">
      <h1 class="style1">&nbsp;</h1>
	  
<?php
include("mg2/index.php");
?>

	    <p>&nbsp;</p>
    </div>
  </div>
  <div id="footer"> 
    <p>Copyright &copy; Elite D&V Services Inc, | <a target="_blank" href="http://validator.w3.org/check?uri=referer">XHTML 1.1</a> | <a target="_blank" href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a>
      
      <a target="_blank" href="http://www.elitedvservices.com">http://www.elitedvservices.com</a></div>  
</div>
  

</div>
</body>
</html>


Thanks,

locobans
Newbie Poster
4 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

First welcome to daniweb as I see your a new poster.
Second, please don't bump really old topics again as it can be really annoying at times. Especially for those who have subscribed to the thread.
And as for the answer, in your /mg2/ directory place a htaccess file with the following code.

order deny<strong>,</strong>allow
deny from all
cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

First welcome to daniweb as I see your a new poster. Second, please don't bump really old topics again as it can be really annoying at times. Especially for those who have subscribed to the thread. And as for the answer, in your /mg2/ directory place a htaccess file with the following code.

order deny<strong>,</strong>allow
deny from all

Thank you and sorry for bumping old topic...

Back to the subject... I did as you told me... and still nothing

This what my root directory .htaccess file looks like

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName elitedvservices.com
AuthUserFile /home/elitedvs/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/elitedvs/public_html/_vti_pvt/service.grp


AddHandler application/x-httpd-php .html
locobans
Newbie Poster
4 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

Thank you and sorry for bumping old topic...

Back to the subject... I did as you told me... and still nothing

This what my root directory .htaccess file looks like

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName elitedvservices.com
AuthUserFile /home/elitedvs/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/elitedvs/public_html/_vti_pvt/service.grp


AddHandler application/x-httpd-php .html

I was meaning that you have 2 htaccess files. The htaccess file you posted plus the following in the directory that has your php files which you don't want people to access (only access through mod_rewrite):

order deny,allow
deny from all

So consider this for an idea. Place your entire website in a foder called /z/ then in the directory /z/ place a htaccess file with the following code:

order deny,allow
deny from all

Just remember the directory name is the letter z lower case
Then in the root directory which is the folder/directory above website place the following .htaccess file which is the same spot you mentioned your previous htaccess file

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName elitedvservices.com
AuthUserFile /home/elitedvs/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/elitedvs/public_html/_vti_pvt/service.grp

RewriteEngine on
/?([^z][^/].*\.html)$ /z/$1.php
/?([^z][^/].*\.[^p][^h][^p])$ /z/$1

That is from the top of my head but you get the point.

cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

I got two .htaccess files...the one on my main root aka public_html containing the info I showed you...

And inside the folder MG2 I have created another one and added just the code you gave me bro...

Thanks,

locobans
Newbie Poster
4 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

So is this solved and I think when you refered to the MG2 folder shouldn't the name of it be just the letter z to match the htaccess files. Then it should be working.

cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You