Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I set apache to process all .html files like .php3 files?

Status
Not open for further replies.
Jun 14, 1999
606
US
Hello,I saw somewhere I can set apache server to process all .html files like they were PHP3 files... say, run <? program ?> in any .html file...How I do that?Thanks in advance...
 
Do you have the directives for php3 files set up in your Apache configuration file?  If you do, why not just rename all your .html files so that they have a .php3 extension?
 
Thaks, but I'm a newbie using <b>apache</b>, I'm a <b>OS/2</b> and <b>BeOS</b> user (but still very very <b>AIX/Unix</b> proficient), I've used other web servers at other platforms.How I do everything you're saying?What I have to edit in <b>/etc/apache/httpd.conf</b>?You can tell me the technical details, I'm a OS/2, Windows NT and AIX/Unix instructor/trainer...<font color=red>Many thanks in advance</font>
 
OK - first thing you need to do is take a look at the Apache documentation that should be available online.&nbsp;&nbsp;Take a look at the &quot;AddHandler&quot; directive.&nbsp;&nbsp;If memory serves, you need to add a &quot;AddHandler&quot; line to the httpd.conf file for &quot;.php3&quot; files.&nbsp;&nbsp;(If you're lucky, this may have already been entered for you if you're using Linux and added PHP as a RPM or similar.)<br><br>Then head over to the PHP documentation and inwardly digest everything you can about how to install it.&nbsp;&nbsp;Make sure your httpd.conf is set up as detailed in the PHP docs.<br><br>Once this is all set up, you should be able to start processing PHP3 files.<br><br>Sorry if this is a bit vague, but I think you'll gain more if you have a read through the PHP docs before heading off to set things up :)&nbsp;&nbsp;If you're still stuck, post back and I'll dig out the configuration details for PHP and post them here :)<br><br>HTH.
 
I know that... and done that, put I want to process the standard .html files like these files were .php or php3<b>Many thanks in advance</b>PS: I'm in a hurry, and developing and <i>testing</i> code...
 
So, if you name a file with a &quot;.php&quot; extension, it gets processed OK?&nbsp;&nbsp;If that's the case, why not just change the &quot;.html&quot; extension on the HTML files to be &quot;.php&quot;?<br><br>In fact, looking back at your original question, if a file contains PHP code, then it should have the .php extension, I think.&nbsp;&nbsp;Then you know it's going to work.<br><br>After all, if you're writing a C program, you put &quot;.c&quot; on the end.&nbsp;&nbsp;If you're writing C++, you use &quot;.cc&quot;.&nbsp;&nbsp;I'm confused as to why you'd need to parse *all* &quot;.html&quot; files as if they were &quot;.php&quot; when the &quot;.php&quot; extension is (presumably) working OK.&nbsp;&nbsp;One thing to consider is that if you are going to parse <b>every</b> html page as PHP then you will be doing a *lot* of extra processing that is just not required.<br><br>If you really have to name all you html files with &quot;php&quot; extensions, then I think you need to take a look in the &quot;http.conf&quot; file.&nbsp;&nbsp;Take a copy of it as it is now (in case of problems).&nbsp;&nbsp;Look through it for the &quot;php&quot; settings and duplicate them, replacing &quot;php&quot; or &quot;php3&quot; with &quot;html&quot; as appropriate.&nbsp;&nbsp;Restart the Apache server and then give it a try.
 
Thanks, I'll try...I'm just counting the accesses to the pages, and is a very dynamic site what I'm building, it's a site for a financial business, and they are showing the US$ to local money conversion rates, bonus, and many financial papers prices here and there... that's the reaso I want to process all HTML files like they were PHP files....Bye.
 
Ah - if you just want to count page accesses, why not parse your access logs once a day, and keep a running total?&nbsp;&nbsp;That should be a lot quicker in the long run than processing every html page on the site.
 
The answer is simple-- in httpd.conf, do a search for the lines that have .php in them.<br><br>There are two places:<br><br>1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DirectoryIndex index.html index.htm index.php index.php3 index.phtml<br><br>(This line sets whatever files you want to be considered as indexes in a directory. You will not need to change this line, unless you want more index choices)<br><br>2.&nbsp;&nbsp;&nbsp;AddType application/x-httpd-php3 .php3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br>or (if you are using PHP4)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AddType application/x-httpd-php .php<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>(In this line you can make as many extensions as you want to parsed as PHP. Just add them to the end--you could even make up extensions -- like .foo, .qwerty or whatever)&nbsp;&nbsp;Change to:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;AddType application/x-httpd-php .php .html<br><br>That one line change will do it. (also, make sure the line you are changing is not commented out with a '#' at the front)<br><br>Then restart Apache and check it out.
 
Thanks for all your help folks!Before reading the last two posts I changed the PHP extension in <b>/etc/apache/httpd.conf</b> to <b>.html</b> and it worked!...One additional reason to use .html and not .php: I'm adding code to&nbsp;&nbsp;pages designed by a Web designers group, and with JavaScript, and I don't want to touch any pages, only my code-only areas.Thanks, many thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top