473,382 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Force apache to parse html files as php

I want apache to parse all .html files for php code. Our 'real' web
server is rented from ICDsoft ( php 5 on Apache on Linux whatever), and
their instruction is to add the following to the .htaccess file:
AddHandler application/x-httpd-php .html
....which works great.

However, our local in-office server for testing and viewing our sites is
Apache 2.0.55 with PHP 4.4.4 on Windows XP Pro. I have read everything
I can find, and have tried adding the following to the httpd.conf file,
in every combination I can think of:
AddHandler application/x-httpd-php .html
and / or:
AddType application/x-httpd-php .php .html

but the page just gets sent as html without the php code being parsed at
all (and yes, I do restart Apache after each change). What am I doing
wrong?

(Here's what httpd.conf contained before--note that it works just fine
for .php files:)
ScriptAlias /php/ "c:/php/"
LoadModule php4_module "c:/php/php4apache2.dll"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php.exe"
PHPIniDir "C:/php"
Dec 5 '07 #1
24 9815
Gary Hasler wrote:
I want apache to parse all .html files for php code. Our 'real' web
server is rented from ICDsoft ( php 5 on Apache on Linux whatever), and
their instruction is to add the following to the .htaccess file:
AddHandler application/x-httpd-php .html
...which works great.

However, our local in-office server for testing and viewing our sites is
Apache 2.0.55 with PHP 4.4.4 on Windows XP Pro. I have read everything
I can find, and have tried adding the following to the httpd.conf file,
in every combination I can think of:
AddHandler application/x-httpd-php .html
and / or:
AddType application/x-httpd-php .php .html

but the page just gets sent as html without the php code being parsed at
all (and yes, I do restart Apache after each change). What am I doing
wrong?

(Here's what httpd.conf contained before--note that it works just fine
for .php files:)
ScriptAlias /php/ "c:/php/"
LoadModule php4_module "c:/php/php4apache2.dll"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php.exe"
PHPIniDir "C:/php"
Just add .html after .php on the AddType line like so:

AddType application/x-httpd-php .php .html

and it should work. Others will tell you that that is a bad idea in that
it causes even pages that have no PHP in them to go through the PHP
parser before getting sent out to the browser. But if you have a need
for it then by all means...

I do:

..php .htm for any page that may be created by or contain PHP generated
output. You can even add your own if you want - doesn't matter. Just
don't over-ride a mime-type.

anything else should get parsed as html or it's respective mime-type. I
personally end static pages (no dynamic) with either .html or .shtml

Norm
Dec 5 '07 #2
Norman Peelman wrote:
>anything else should get parsed as html or it's respective mime-type.
http://groups.google.co.uk/group/alt...strophe/topics

Dec 5 '07 #3
Norman Peelman wrote:
>
Gary Hasler wrote:
I want apache to parse all .html files for php code. Our 'real' web
server is rented from ICDsoft ( php 5 on Apache on Linux whatever), and
their instruction is to add the following to the .htaccess file:
AddHandler application/x-httpd-php .html
...which works great.

However, our local in-office server for testing and viewing our sites is
Apache 2.0.55 with PHP 4.4.4 on Windows XP Pro. I have read everything
I can find, and have tried adding the following to the httpd.conf file,
in every combination I can think of:
AddHandler application/x-httpd-php .html
and / or:
AddType application/x-httpd-php .php .html

but the page just gets sent as html without the php code being parsed at
all (and yes, I do restart Apache after each change). What am I doing
wrong?

(Here's what httpd.conf contained before--note that it works just fine
for .php files:)
ScriptAlias /php/ "c:/php/"
LoadModule php4_module "c:/php/php4apache2.dll"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php.exe"
PHPIniDir "C:/php"

Just add .html after .php on the AddType line like so:

AddType application/x-httpd-php .php .html

and it should work. Others will tell you that that is a bad idea in that
it causes even pages that have no PHP in them to go through the PHP
parser before getting sent out to the browser. But if you have a need
for it then by all means...

I do:

.php .htm for any page that may be created by or contain PHP generated
output. You can even add your own if you want - doesn't matter. Just
don't over-ride a mime-type.

anything else should get parsed as html or it's respective mime-type. I
personally end static pages (no dynamic) with either .html or .shtml

Norm
Thanks Norm;
however I figured out what was happening (always happens if I post a
question!)..
I had SSI turned on earlier in the httpd.conf and I guess it can't do
both?:

<Directory />
Options Indexes FollowSymLinks
Options +Includes
AddType text/html .shtml

# --THESE LINES HAD TO BE DELETED:
#AddOutputFilter INCLUDES .html
#AddHandler server-parsed .html
</Directory>
Dec 5 '07 #4
On Wed, 05 Dec 2007 19:40:29 +0000, Gary Hasler wrote:
I want apache to parse all .html files for php code.
May I ask why files that contain PHP code are being named .html and not
..php?

--
I told you this was going to happen.

Dec 5 '07 #5
..oO(Ivan Marsh)
>On Wed, 05 Dec 2007 19:40:29 +0000, Gary Hasler wrote:
>I want apache to parse all .html files for php code.

May I ask why files that contain PHP code are being named .html and not
.php?
Some things simply don't belong to a URL.

Cool URIs don't change
http://www.w3.org/Provider/Style/URI

| What to leave out
| [...]
| * File name extension. This is a very common one. "cgi", even ".html"
| is something which will change. You may not be using HTML for that
| page in 20 years time, but you might want today's links to it to
| still be valid. The canonical way of making links to the W3C site
| doesn't use the extension.
| * Software mechanisms. Look for "cgi", "exec" and other give-away
| "look what software we are using" bits in URIs. Anyone want to
| commit to using perl cgi scripts all their lives? Nope? Cut out the
| .pl. Read the server manual on how to do it.

Micha
Dec 5 '07 #6
On Wed, 05 Dec 2007 22:20:58 +0100, Michael Fesser wrote:
.oO(Ivan Marsh)
>>On Wed, 05 Dec 2007 19:40:29 +0000, Gary Hasler wrote:
>>I want apache to parse all .html files for php code.

May I ask why files that contain PHP code are being named .html and not
.php?

Some things simply don't belong to a URL.
Who said anything about belonging in a URL? If you're stripping file
extensions what difference does it make what the file extension is?

The file extension tells the webserver how to interpret the file... so why
not name PHP scripts .php rather than .html?

--
I told you this was going to happen.

Dec 5 '07 #7
Paul Lautman wrote:
Norman Peelman wrote:
>anything else should get parsed as html or it's respective mime-type.
http://groups.google.co.uk/group/alt...strophe/topics
It does in the proper context... which I didn't use. :)

Norm
Dec 5 '07 #8
On Wed, 05 Dec 2007 22:20:58 +0100, Michael Fesser <ne*****@gmx.dewrote:
.oO(Ivan Marsh)
>On Wed, 05 Dec 2007 19:40:29 +0000, Gary Hasler wrote:
>>I want apache to parse all .html files for php code.

May I ask why files that contain PHP code are being named .html and not
.php?

Some things simply don't belong to a URL.

Cool URIs don't change
http://www.w3.org/Provider/Style/URI
.... and URI's have little to do with where the request ends up on a sever
anyway...

Come to think of it, close to none of my recent projects use any URI
ending in an extension, save for some back-end/CMS functionality not
publically available. They are a way to advertise to search engines/make
them accessable by guessability/should reflect some sort of indication of
the actual content they'll show, so I treat them as such.
--
Rik Wasmus
Dec 5 '07 #9
On 5 Dec, 19:40, Gary Hasler <garyhas...@thelogconnection.comwrote:
I want apache to parse all .html files for php code. Our 'real' web
server is rented from ICDsoft ( php 5 on Apache on Linux whatever), and
their instruction is to add the following to the .htaccess file:
AddHandler application/x-httpd-php .html
...which works great.

However, our local in-office server for testing and viewing our sites is
Apache 2.0.55 with PHP 4.4.4 on Windows XP Pro.
At the risk of being annoying: a test system isn't much of a test if
it doesn't duplicate
the target system.

Dec 6 '07 #10
On 5 Dec, 22:06, Norman Peelman <npeel...@cfl.rr.comwrote:
Paul Lautman wrote:
Norman Peelman wrote:
anything else should get parsed as html or it's respective mime-type.
http://groups.google.co.uk/group/alt....no.apostrophe...

It does in the proper context... which I didn't use. :)

Norm
No, there is no context where a posseive its has an apostrophe.
Dec 6 '07 #11
Gremnebulin wrote:
>
On 5 Dec, 19:40, Gary Hasler <garyhas...@thelogconnection.comwrote:
I want apache to parse all .html files for php code. Our 'real' web
server is rented from ICDsoft ( php 5 on Apache on Linux whatever), and
their instruction is to add the following to the .htaccess file:
AddHandler application/x-httpd-php .html
...which works great.

However, our local in-office server for testing and viewing our sites is
Apache 2.0.55 with PHP 4.4.4 on Windows XP Pro.

At the risk of being annoying: a test system isn't much of a test if
it doesn't duplicate
the target system.
True; but I'm getting better--it used to be Microsoft IIS!
I guess I should set up Apache the way ICDsoft does, and then create
identical .htaccess files, maybe someday..
As far as the OS goes, the only quirks I've run into are:
- Windows won't let me create a file named .htaccess
- The case-sensitive filename issue
Right now I do a lot of work in Windows-only software, so it's just
easier to run the test site on windows. Some day I'll get a Linux
server and set it up JUST right!
Dec 6 '07 #12
Ivan Marsh wrote:
>
On Wed, 05 Dec 2007 22:20:58 +0100, Michael Fesser wrote:
.oO(Ivan Marsh)
>On Wed, 05 Dec 2007 19:40:29 +0000, Gary Hasler wrote:

I want apache to parse all .html files for php code.

May I ask why files that contain PHP code are being named .html and not
.php?
Some things simply don't belong to a URL.

Who said anything about belonging in a URL? If you're stripping file
extensions what difference does it make what the file extension is?

The file extension tells the webserver how to interpret the file... so why
not name PHP scripts .php rather than .html?
Because I'm switching to a PHP scripted menu / header include system,
that means I will need all 50 of our existing html pages to be processed
by PHP. And I'd rather not break our customers' existing bookmarks,
plus search engine links.
Dec 6 '07 #13
rf

"Gary Hasler" <ga********@thelogconnection.comwrote in message
news:47***************@thelogconnection.com...
Gremnebulin wrote:
- Windows won't let me create a file named .htaccess
Windows Explorer won't. The file system does not care. So, start up notepad
and save the file as ".htaccess", including the quotes. No problem.
- The case-sensitive filename issue
I've never had a problem. Then again *all* my filenames are lower case.

--
Richard.
Dec 7 '07 #14
Captain Paralytic wrote:
On 5 Dec, 22:06, Norman Peelman <npeel...@cfl.rr.comwrote:
>Paul Lautman wrote:
>>Norman Peelman wrote:
anything else should get parsed as html or it's respective mime-type.
http://groups.google.co.uk/group/alt....no.apostrophe...
It does in the proper context... which I didn't use. :)

Norm

No, there is no context where a posseive its has an apostrophe.
Exactly. I didn't use it properly, it's not meant to be possessive.
It's a typo.
---
Norm
Dec 7 '07 #15
Gary Hasler wrote:
I want apache to parse all .html files for php code. Our 'real' web
server is rented from ICDsoft ( php 5 on Apache on Linux whatever), and
their instruction is to add the following to the .htaccess file:
AddHandler application/x-httpd-php .html
...which works great.

However, our local in-office server for testing and viewing our sites is
Apache 2.0.55 with PHP 4.4.4 on Windows XP Pro. I have read everything
I can find, and have tried adding the following to the httpd.conf file,
in every combination I can think of:
AddHandler application/x-httpd-php .html
and / or:
AddType application/x-httpd-php .php .html

but the page just gets sent as html without the php code being parsed at
all (and yes, I do restart Apache after each change). What am I doing
wrong?

(Here's what httpd.conf contained before--note that it works just fine
for .php files:)
ScriptAlias /php/ "c:/php/"
LoadModule php4_module "c:/php/php4apache2.dll"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php.exe"
PHPIniDir "C:/php"

Also take a look at the 'AccessFileName' directive. It's a directive
that allows you to change the name of .htaccess files if you so desire.

---
Norm
Dec 7 '07 #16
On 6 Dec, 23:23, Gary Hasler <garyhas...@thelogconnection.comwrote:
True; but I'm getting better--it used to be Microsoft IIS!
I guess I should set up Apache the way ICDsoft does, and then create
identical .htaccess files, maybe someday..
As far as the OS goes, the only quirks I've run into are:
- Windows won't let me create a file named .htaccess
- The case-sensitive filename issue
Right now I do a lot of work in Windows-only software, so it's just
easier to run the test site on windows. Some day I'll get a Linux
server and set it up JUST right!

All you need is a linux CD. The current PC could be converted into a
dual-boot system.
Dec 7 '07 #17
Norman Peelman wrote:
Captain Paralytic wrote:
>On 5 Dec, 22:06, Norman Peelman <npeel...@cfl.rr.comwrote:
>>Paul Lautman wrote:
Norman Peelman wrote:
anything else should get parsed as html or it's respective
mime-type.
http://groups.google.co.uk/group/alt....no.apostrophe...
It does in the proper context... which I didn't use. :)

Norm

No, there is no context where a posseive its has an apostrophe.

Exactly. I didn't use it properly, it's not meant to be possessive.
It's a typo.
Err, the english is fine apart from the apostrophe. a file has a mime type
and so the mime type is possessed by the file, therefore the "its" indicates
that the file possesses a mime type.

If you intended it as an abbreviation, you would have been saying
"anything else should get parsed as html or it is respective mime-type."

which is utter nonesense.

Dec 8 '07 #18
Paul Lautman wrote:
Norman Peelman wrote:
>Captain Paralytic wrote:
>>On 5 Dec, 22:06, Norman Peelman <npeel...@cfl.rr.comwrote:
Paul Lautman wrote:
Norman Peelman wrote:
>anything else should get parsed as html or it's respective
>mime-type.
http://groups.google.co.uk/group/alt....no.apostrophe...
It does in the proper context... which I didn't use. :)

Norm
No, there is no context where a posseive its has an apostrophe.
Exactly. I didn't use it properly, it's not meant to be possessive.
It's a typo.

Err, the english is fine apart from the apostrophe. a file has a mime type
and so the mime type is possessed by the file, therefore the "its" indicates
that the file possesses a mime type.

If you intended it as an abbreviation, you would have been saying
"anything else should get parsed as html or it is respective mime-type."

which is utter nonesense.
How many times do I have to admit I should have left the apostrophe
out. Yes, I know it was supposed to be 'its.' But hey, thanks again...

---
Norm
Dec 8 '07 #19
Norman Peelman wrote:
Paul Lautman wrote:
>Norman Peelman wrote:
>>Captain Paralytic wrote:
On 5 Dec, 22:06, Norman Peelman <npeel...@cfl.rr.comwrote:
Paul Lautman wrote:
>Norman Peelman wrote:
>>anything else should get parsed as html or it's respective
>>mime-type.
>http://groups.google.co.uk/group/alt....no.apostrophe...
It does in the proper context... which I didn't use. :)
>
Norm
No, there is no context where a posseive its has an apostrophe.
Exactly. I didn't use it properly, it's not meant to be
possessive. It's a typo.

Err, the english is fine apart from the apostrophe. a file has a
mime type and so the mime type is possessed by the file, therefore
the "its" indicates that the file possesses a mime type.

If you intended it as an abbreviation, you would have been saying
"anything else should get parsed as html or it is respective
mime-type." which is utter nonesense.

How many times do I have to admit I should have left the apostrophe
out. Yes, I know it was supposed to be 'its.' But hey, thanks
again...
But you didn't say that you should have left the apostrophe out, you said
that it wasn't meant to be possessive.

Dec 8 '07 #20
Paul Lautman wrote:
Norman Peelman wrote:
>Paul Lautman wrote:
>>Norman Peelman wrote:
Captain Paralytic wrote:
On 5 Dec, 22:06, Norman Peelman <npeel...@cfl.rr.comwrote:
>Paul Lautman wrote:
>>Norman Peelman wrote:
>>>anything else should get parsed as html or it's respective
>>>mime-type.
>>http://groups.google.co.uk/group/alt....no.apostrophe...
>It does in the proper context... which I didn't use. :)
>>
>Norm
No, there is no context where a posseive its has an apostrophe.
Exactly. I didn't use it properly, it's not meant to be
possessive. It's a typo.
Err, the english is fine apart from the apostrophe. a file has a
mime type and so the mime type is possessed by the file, therefore
the "its" indicates that the file possesses a mime type.

If you intended it as an abbreviation, you would have been saying
"anything else should get parsed as html or it is respective
mime-type." which is utter nonesense.
How many times do I have to admit I should have left the apostrophe
out. Yes, I know it was supposed to be 'its.' But hey, thanks
again...
But you didn't say that you should have left the apostrophe out, you said
that it wasn't meant to be possessive.
I mis-stated that comment. It was meant to be possessive but I
should have left the apostrophe out to do so. I made a mistake. My
fingers were going faster than my brain as usual.

Norm
Dec 8 '07 #21
Norman Peelman wrote:
Paul Lautman wrote:
>Norman Peelman wrote:
>>Captain Paralytic wrote:
On 5 Dec, 22:06, Norman Peelman <npeel...@cfl.rr.comwrote:
Paul Lautman wrote:
>Norman Peelman wrote:
>>anything else should get parsed as html or it's respective
>>mime-type.
>http://groups.google.co.uk/group/alt....no.apostrophe...
>>
It does in the proper context... which I didn't use. :)
>
Norm
No, there is no context where a posseive its has an apostrophe.
Exactly. I didn't use it properly, it's not meant to be possessive.
It's a typo.

Err, the english is fine apart from the apostrophe. a file has a mime
type and so the mime type is possessed by the file, therefore the
"its" indicates that the file possesses a mime type.

If you intended it as an abbreviation, you would have been saying
"anything else should get parsed as html or it is respective mime-type."

which is utter nonesense.

How many times do I have to admit I should have left the apostrophe
out. Yes, I know it was supposed to be 'its.' But hey, thanks again...

---
Norm
Normal,

Don't worry about it. Paul catches me on this rather regularly, also,
and I DO know better. :-)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Dec 9 '07 #22
Gary Hasler:
Because I'm switching to a PHP scripted menu / header include system,
that means I will need all 50 of our existing html pages to be processed
by PHP. And I'd rather not break our customers' existing bookmarks,
plus search engine links.
Enable MultiViews and add .php to .html filenames.

--
Jock
Dec 10 '07 #23
rf wrote:
>
"Gary Hasler" <ga********@thelogconnection.comwrote in message
news:47***************@thelogconnection.com...
Gremnebulin wrote:
- Windows won't let me create a file named .htaccess

Windows Explorer won't. The file system does not care. So, start up notepad
and save the file as ".htaccess", including the quotes. No problem.
Hey!...I learn sumthin' every day!
Dec 10 '07 #24
Gremnebulin <pe*********@yahoo.comwrote:
>
All you need is a linux CD. The current PC could be converted into a
dual-boot system.
I've heard that worded slightly differently: "You need to upgrade your
Windows XP system by applying Service Pack Linux."
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Dec 11 '07 #25

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Terence | last post by:
A curious observation: I have my apache web server configured for the PHP apache module to parse files ending in the .php extension. nothing unusual about that, but I also noticed that if I...
27
by: Mxsmanic | last post by:
How can I combine SSI, CGI, and PHP in Apache 2.x? I keep reading that this can be done, but I haven't found any examples of the actual configuration required to do it. What I want to do is: ...
2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
1
by: Rolfe | last post by:
Hi, I struggled, and got mod_python running on Apache/Win2k. Follow these instructions verbatim and you shouldn't have any trouble. These instructions are based on...
14
by: Jim Carlock | last post by:
I have a couple easy questions possibly. 1) Is there a default.php page? The webserver seems to support default.htm, default.html, index.htm and index.html. It's an Apache server, I'd like to...
6
by: MaiyaHolliday | last post by:
Hello, I've recently installed apache on a new computer, and cannot figure out why my site will not process any includes. (it was working on my old one) There are no errors on the page such as...
11
by: =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?= | last post by:
With Apache's mod_rewrite module I can keep *.php files and load them as *.html files: # Make http//example.com/foo/bar.html load /home/site/foo/bar.php RewriteEngine On RewriteRule...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
6
by: josequinonesii | last post by:
I've searched, I've read, I've tested and re-read numerous post but to no avail yet... Quite simply, the settings I've applied to my httpd.conf, httpd-vhost.conf and my hosts files simply does not...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.