473,395 Members | 1,956 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,395 software developers and data experts.

php in ".html" documents

Hi,

On my computer apache will see php in .php documents but not in .html
documents. Can I configure apache to see php in .html documents? Or is
this something that cannot be done at all?

Thanks,
Peter

Jul 17 '05 #1
28 1877
pe**********@yahoo.com wrote:
Hi,

On my computer apache will see php in .php documents but not in .html
documents. Can I configure apache to see php in .html documents? Or is
this something that cannot be done at all?


Rename the .html file as .php! ;-)
--
Optirectumitis - where the optic nerve gets crossed with the rectal
nerve resulting in a crappy outlook on life.

Jul 17 '05 #2
pe**********@yahoo.com wrote:
: Hi,

: On my computer apache will see php in .php documents but not in .html
: documents. Can I configure apache to see php in .html documents? Or is
: this something that cannot be done at all?

Yes. The apache config file can be used to control how apache handles a
file. So just tell apache to handle all html files within some area as if
they were php files, As long as they don't use <?php for some other reason
then everything should work like you want (though slower for the files in
that area).

Because the html files are really programs you must be more careful with
security.

You'll have to lookup the details though, I don't have an example I can
easily refer to or test.

(Caveat, I haven't done exactly this task ever, only things that are
pretty similar.)
--

This space not for rent.
Jul 17 '05 #3
> On my computer apache will see php in .php documents but not in .html
documents. Can I configure apache to see php in .html documents? Or is
this something that cannot be done at all?


Add this to .htaccess:

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

Jul 17 '05 #4
Dan Fulbright wrote:
On my computer apache will see php in .php documents but not in .html
documents. Can I configure apache to see php in .html documents? Or
is this something that cannot be done at all?


Add this to .htaccess:

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


I don't think it particularly wise to have all .html files always
treated and processed as .php files. That's why I said "If you want a
..html file to be treated as a .php file then rename it".

--
If it's zero degrees outside today and it's supposed to be twice as cold
tomorrow, how cold is it going to be?

Jul 17 '05 #5
Which was an answer to a question that wasn't asked.
I don't think it particularly wise to have all .html files always treated
and processed as .php files. That's why I said "If you want a .html file to
be treated as a .php file then rename it".

--
If it's zero degrees outside today and it's supposed to be twice as cold
tomorrow, how cold is it going to be?
Jul 17 '05 #6
On Tue, 21 Jun 2005 05:31:48 +0000, Andrew DeFaria wrote:
Dan Fulbright wrote:
On my computer apache will see php in .php documents but not in .html
documents. Can I configure apache to see php in .html documents? Or is
this something that cannot be done at all?


Add this to .htaccess:

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


I don't think it particularly wise to have all .html files always treated
and processed as .php files. That's why I said "If you want a .html file
to be treated as a .php file then rename it".


Particularly unwise if the pages will be used on any other server than his
own.

Jul 17 '05 #7
Michel wrote:
Which was an answer to a question that wasn't asked.

I don't think it particularly wise to have all .html files always
treated and processed as .php files. That's why I said "If you want a
.html file to be treated as a .php file then rename it".


Huh?
--
I'm not tense, just terribly, terribly alert.
Jul 17 '05 #8
Another nameless somebody wrote:
On my computer apache will see php in .php documents but not in .html
documents. Can I configure apache to see php in .html documents?


<.html.php>?

--
Jock
Jul 17 '05 #9
Michel wrote:
Which was an answer to a question that wasn't asked.


which is alright in my book!!
'top posting'

[just for you, Michel, that was another answer to a question
that wasn't asked - can you tell what it is yet?]

--
Jock
Jul 17 '05 #10
Michel (no@spam.please) wrote:

: I don't think it particularly wise to have all .html files always treated
: and processed as .php files. That's why I said "If you want a .html file to
: be treated as a .php file then rename it".

which is why I suggested that this be defined for "an area" within the
server.

One reason to treat html as php might be because a site has pages that
have been static in the past, and they wish to enhance those pages to be
dynamic without breaking any existing links.

Rewrite rules could do that to, but simply turning on php for html sounds
like the easiest way to do it, perhaps as a temporary measure during some
conversion period.
--

This space not for rent.
Jul 17 '05 #11
Malcolm Dew-Jones wrote:
Michel (no@spam.please) wrote:

: I don't think it particularly wise to have all .html files always
treated
: and processed as .php files. That's why I said "If you want a .html
file to
: be treated as a .php file then rename it".

which is why I suggested that this be defined for "an area" within the
server.

One reason to treat html as php might be because a site has pages that
have been static in the past, and they wish to enhance those pages to
be dynamic without breaking any existing links.

Rewrite rules could do that to, but simply turning on php for html
sounds like the easiest way to do it, perhaps as a temporary measure
during some conversion period.


It's the wrong way to go about it. Rename the files from .html -> .php
and adjust the corresponding links - that's the proper way.
--
Sign seen in a bar: "Those drinking to forget please pay in advance"

Jul 17 '05 #12
Andrew DeFaria (An****@DeFaria.com) wrote:
: This is a multi-part message in MIME format.
: --------------020109070304080007040301
: Content-Type: text/plain; charset=ISO-8859-1; format=flowed
: Content-Transfer-Encoding: 7bit

: Malcolm Dew-Jones wrote:

: > Michel (no@spam.please) wrote:
: >
: > : I don't think it particularly wise to have all .html files always
: > treated
: > : and processed as .php files. That's why I said "If you want a .html
: > file to
: > : be treated as a .php file then rename it".
: >
: > which is why I suggested that this be defined for "an area" within the
: > server.
: >
: > One reason to treat html as php might be because a site has pages that
: > have been static in the past, and they wish to enhance those pages to
: > be dynamic without breaking any existing links.
: >
: > Rewrite rules could do that to, but simply turning on php for html
: > sounds like the easiest way to do it, perhaps as a temporary measure
: > during some conversion period.

: It's the wrong way to go about it. Rename the files from .html -> .php
: and adjust the corresponding links - that's the proper way.

Hum, lets get this right, I change the name and then ask google, or any
number of other sites that link to me, to change their links.

Could you explain how that works again...
--

This space not for rent.
Jul 17 '05 #13
Malcolm Dew-Jones wrote:.
Hum, lets get this right, I change the name and then ask google, or
any number of other sites that link to me, to change their links.

Could you explain how that works again...


Links that cross sites were never, repeat never meant to be golden. They
change when they change. You cannot control the world and you cannot
rely that links will remain constant forever. Google will eventually
automatically adapt anyway.

What are you suggesting in your scenario anyway? That people open up a
potential security hole changing all of their .html files to be run as
though they are .php forever?
--
Hang up and drive.

Jul 17 '05 #14
Malcolm Dew-Jones wrote:
Andrew DeFaria (An****@DeFaria.com) wrote:
: This is a multi-part message in MIME format.
: --------------020109070304080007040301
: Content-Type: text/plain; charset=ISO-8859-1; format=flowed
: Content-Transfer-Encoding: 7bit

: Malcolm Dew-Jones wrote:

: > Michel (no@spam.please) wrote:
: >
: > : I don't think it particularly wise to have all .html files always
: > treated
: > : and processed as .php files. That's why I said "If you want a .html
: > file to
: > : be treated as a .php file then rename it".
: >
: > which is why I suggested that this be defined for "an area" within the
: > server.
: >
: > One reason to treat html as php might be because a site has pages that
: > have been static in the past, and they wish to enhance those pages to
: > be dynamic without breaking any existing links.
: >
: > Rewrite rules could do that to, but simply turning on php for html
: > sounds like the easiest way to do it, perhaps as a temporary measure
: > during some conversion period.

: It's the wrong way to go about it. Rename the files from .html -> .php
: and adjust the corresponding links - that's the proper way.

Hum, lets get this right, I change the name and then ask google, or any
number of other sites that link to me, to change their links.

Could you explain how that works again...
--

This space not for rent.


Just set up a permanent redirect from the old file to the new one.
Google will adjust accordingly when it next spiders.

Simple, really. And, like Michel said, it's the proper way to do
things. After all - what happens if, for instance, your hosting company
goes under - and your new host doesn't allow you to parse .html files
for php?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #15
Jerry Stuckle wrote:
After all - what happens if, for instance, your hosting company
goes under - and your new host doesn't allow you to parse .html files
for php?


You give them a right good clobbering with a clue-stick??

--
Jock
Jul 17 '05 #16
Andrew DeFaria wrote:
Rename the files from .html -> .php
If the reason for having it in the first place is still there,
why would you take the <.html> off?
and adjust the corresponding links
That's just not feasible in every case. It's impossible to
know where all the links are - if it's on the WWW - let alone
change each one. (HTTP redirects are a poor man's workaround
for this mess though.)
- that's the proper way.


If you did it differently, I doubt if Peggy Post would fall
over herself to protest.

--
Jock
Jul 17 '05 #17
Andrew DeFaria <An****@DeFaria.com> wrote in news:BoKte.1427$p%3.11209
@typhoon.sonic.net:

Andrew,

You seem to feel pretty vociferously that it's a bad idea to embed php
within .html files, or any other files for that matter. I'd like to get
some idea as to why you feel this is such a horrible idea. For me, I'd
just as soon end users didn't know they were looking at a php page, which
is why I tend to use the .htaccess fix.

So, what's your reasoning for feeling it's such a bad idea? I'd like to
know. If there's a good reason not to do this, then I'll stop.

--
Randy Jackson
HTTP://FourColorExplosion.com
Jul 17 '05 #18
John Dunlop wrote:
Andrew DeFaria wrote:
Rename the files from .html -> .php
If the reason for having it in the first place is still there, why
would you take the <.html> off?


Huh? What are you talking about? What's the "reason for having it in the
first place"? Answer: Because it's a static web page! What's the reason
for renaming it (pay attention it's not taking .html off! It's renaming
it from .html *to* .php!)? Answer: Because it's now no longer a static
web page but a dynamic one parsed by PHP!
and adjust the corresponding links


That's just not feasible in every case.


Bullshit! It may not be feasible for you because you don't know how to
use your OS or lack good tools, but it's really not that difficult.
It's impossible to know where all the links are
It's called grep! Look it up!
- if it's on the WWW
What's "on the WWW" mean?!? Your web site is nothing more than a
collection of files.
- let alone change each one.
It's called sed, or Perl, or dare I say PHP.
(HTTP redirects are a poor man's workaround for this mess though.)


Agreed.
- that's the proper way.


If you did it differently, I doubt if Peggy Post would fall over
herself to protest.


WTF are you talking about anyway?!?

(Some people will make up any excuse they can thing of and expend so
much energy avoiding doing the proper thing it's frigging ridiculous!)
--
A husband is someone who takes out the trash and gives the impression he
just cleaned the whole house.

Jul 17 '05 #19
Randy Jackson wrote:
You seem to feel pretty vociferously that it's a bad idea to embed php
within .html files, or any other files for that matter. I'd like to
get some idea as to why you feel this is such a horrible idea. For me,
I'd just as soon end users didn't know they were looking at a php
page, which is why I tend to use the .htaccess fix.

So, what's your reasoning for feeling it's such a bad idea? I'd like
to know. If there's a good reason not to do this, then I'll stop.


Why do you name a file .html? I mean why not choose the extension of
..foo? Why does Windows name executables .exe and Excel files .xls?
Simple, to indicate and distinguish that this file is different and or
processed differently than other files. IOW there's a reason and that is
indeed the reason. There really doesn't need to be another reason now
does there?

However the server will also be taxed in to parsing all .html files
looking for executable PHP code if you configure it that way. Seems like
a waste of processing time to me. There are also things such as "server
parsed html" normally named .shtml. Why is that? I mean why not make all
..html files the same as .shtml files? Well as the docs say you don't
want the server have to parse each html file as if it were a .shtml file
- it's wasteful. How then is this different for PHP?

And there may be some additional exposure to a security problem by doing
this (This I'm not as sure about - IOW it's probably harmless from a
security perspective).

Finally I fail to see why there is such push to use a sledge hammer
approach to fix a problem that really has a quite definite direction for
a proper solution. Is renaming a few files that hard to do? Is finding
links to those pages that hard to do? A simple script run over the set
of .html files seems like probably something much simpler of a script
than most scripts that people are writing here in PHP pages! Come on
people, can't you program? If not then what are you doing in a PHP
newsgroup?!?

The time spent arguing why renaming the files involved from .html ->
..php and finding and adjusting any links to it properly is probably a
lot less than the time, energy and effort spent here justifying why a
sledge hammer approach is preferred. It always amazes me how people
spend more energy avoiding a task then actually doing it!
--
I used to have a handle on life, then it broke.
Jul 17 '05 #20
I know you probably don't care to hear this but:

This could also slow down server performance a little, as every .html
file will have to be parsed to see if it contains php.

--
PHP Stuff:
www.douglassdavis.com

Jul 17 '05 #21
Andrew DeFaria (An****@DeFaria.com) wrote:

: John Dunlop wrote:

: > Andrew DeFaria wrote:
: >

: >> and adjust the corresponding links
: >
: > That's just not feasible in every case.

: Bullshit! It may not be feasible for you because you don't know how to
: use your OS or lack good tools, but it's really not that difficult.

Well lets see, my customer inserts the CD they bought a couple of years
ago and clicks on the help button that says - "go here to look for
updates"

I'm afraid I'm not clear which tool will update my customers CD.

(Oh yes I forgot, according to you that link isn't "golden", my customers
should not expect to be able to reach the relevant section of my web site
from the link on the CD they bought last year.)
: > It's impossible to know where all the links are

: It's called grep! Look it up!

I'm not acquainted with that version of grep. Better keep it out of the
hands of muggles though, it sounds like a powerful tool, traversing school
news letters, business cards, and government pamphlets in its quest to
hunt down the places your web addresses are mentioned.
--

This space not for rent.
Jul 17 '05 #22
www.douglassdavis.com (do************@earthlink.net) wrote:
: I know you probably don't care to hear this but:

: This could also slow down server performance a little, as every .html
: file will have to be parsed to see if it contains php.

Which is why I said "an area" of the server might be configured to this so
that only some sets of files are impacted.

And if many of those html files contain php then they are going to be
scanned anyway.

And unless your server has a performance issue then the processing is
irrelevent. The old adage about optimizing after identifying the
performance problems applies here as elsewhere. If your cpu is 20% busy
then it makes little difference if things take twice as many cycles, as
long as the over all response is still ok for the end user.

And if performance is a problem then perhaps those pages should be
pre-generated on a timely schedule instead of being truly dynamic - and of
course then we'll have to change the names back to html because they are
no longer quite so dynamic as before, and we'll end up having the
identical discussion but in reverse.

--

This space not for rent.
Jul 17 '05 #23
Andrew DeFaria (An****@DeFaria.com) wrote:
: Randy Jackson wrote:

: > You seem to feel pretty vociferously that it's a bad idea to embed php
: > within .html files, or any other files for that matter. I'd like to
: > get some idea as to why you feel this is such a horrible idea. For me,
: > I'd just as soon end users didn't know they were looking at a php
: > page, which is why I tend to use the .htaccess fix.
: >
: > So, what's your reasoning for feeling it's such a bad idea? I'd like
: > to know. If there's a good reason not to do this, then I'll stop.
: And there may be some additional exposure to a security problem by doing
: this (This I'm not as sure about - IOW it's probably harmless from a
: security perspective).

Yes, .html files as php is a security concern because it's easier for
someone to install a cgi script without your knowledge. A hacker could
add a <?php section to your home page and you might not know for a long
time that it was now doing something on the side everytime a person
visited your site. A legitimate but unprivileged user could upload an
html file and not even realize it is a script - i.e. it's just plain
harder to control since the type of file is not as obvious to the
administrators.

But the reverse is just as likely to be true.

A .php file is a target for certain hackers because it shows the site is
running cgi-like scripts, whereas a site that appears to be static has
less obvious reasons and hooks for a hacker to check. The .php extension
also shows what type of programming is being used, just like the extension
..asp shows it's an NT server with asp capabilities.

There is no good reason to give out this kind of information any more than
you have to.

In either case, if you are able to run scripts at all then security is
more of a concern than if your web server refuses to run them.

--

This space not for rent.
Jul 17 '05 #24
Malcolm Dew-Jones <yf***@vtn1.victoria.tc.ca> wrote:

: >> and adjust the corresponding links
: >
: > That's just not feasible in every case.

: Bullshit! It may not be feasible for you because you don't know how to
: use your OS or lack good tools, but it's really not that difficult.

Well lets see, my customer inserts the CD they bought a couple of years
ago and clicks on the help button that says - "go here to look for
updates"

I'm afraid I'm not clear which tool will update my customers CD.


Ahhhh, never seen this happen before.... aren't we lucky dead links
don't exist :)

If you communicate such URL you should keep in mind that the
implementation on the server could change over time. But carefully
chosen it could survive for a long time eg don't link to the index
"file", link to the "directory" instead. That solves a move from a php
based httpd with /index.php to eg an ASP based machine with
/default.asp. If possible don't use extensions, let the httpd figure out
what to send. Some servers support url rewriting make moves transparant
for the client. Or simply use clientside solutions to point to the new
location.

Jul 17 '05 #25
Andrew DeFaria wrote:
John Dunlop wrote:
Andrew DeFaria wrote:
Rename the files from .html -> .php
If the reason for having it in the first place is still there, why
would you take the <.html> off?


Huh? What are you talking about? What's the "reason for having it in the
first place"? Answer: Because it's a static web page!


a text/html file, Shirley?
What's the reason for renaming it (pay attention it's not taking .html
off! It's renaming it from .html *to* .php!)?


I misunderstood you. When you wrote 'from .html -> .php', I
got the impression that you meant <.html> no longer occurs as
a filename extension, that you replaced it with <.php>. (In
fact I still have trouble not reading it as that.)

Skipping to the next bit...
and adjust the corresponding links

[so now we've moved from talking about filenames to talking
about addresses]
That's just not feasible in every case.


Bullshit!


We're talking cross purposes then. I'm talking the whole wide
world, you're talking local filesystem, and I expect you'll
agree they're two very different things!

--
Jock
Jul 17 '05 #26
[Outlook]..... is also an answer to a question... I think you know what it
is.
;-)

"John Dunlop" <us*********@john.dunlop.name> wrote in message
news:MP***********************@news.ntlworld.com.. .
Michel wrote:
Which was an answer to a question that wasn't asked.


which is alright in my book!!
'top posting'

[just for you, Michel, that was another answer to a question
that wasn't asked - can you tell what it is yet?]

--
Jock

Jul 17 '05 #27
Michel wrote:
[Outlook]..... is also an answer to a question... I think you know what it
is.
An old joke, slightly adapted here:

'Outlook' is not the answer. 'Outlook' is the question, and
the answer is 'no'.

['QuoteFix' yet another, but now the questions are getting
harder to guess]
;-)


Of course!

--
Jock
Jul 17 '05 #28
As long as top quoted lines show up first, without me having to scroll all
the time.... the answer applies to a question I am asking you....

LoL.... that was a good one b.t.w. ;-)

"John Dunlop" <us*********@john.dunlop.name> wrote in message
news:MP************************@news.ntlworld.com. ..
Michel wrote:
[Outlook]..... is also an answer to a question... I think you know what it is.


An old joke, slightly adapted here:

'Outlook' is not the answer. 'Outlook' is the question, and
the answer is 'no'.

['QuoteFix' yet another, but now the questions are getting
harder to guess]
;-)


Of course!

--
Jock

Jul 17 '05 #29

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

Similar topics

6
by: Nickolay Kolev | last post by:
Hi all, I am looking for a way to extract the titles of HTML documents. I have made an honest attempt at doing it, and it even works. Is there an easier (faster / more efficient / clearer) way?...
0
by: C. Barnes | last post by:
htmldata 1.0.4 is available. http://oregonstate.edu/~barnesc/htmldata/ The htmldata module allows one to translate HTML documents back and forth to list data structures. This allows for...
2
by: Eliza Zadura | last post by:
Is there a way to transform an XML into several result HTML-documents? I am working with rather large XML-files as input and the desired output is primarily HTML and am looking for a way to produce...
1
by: David Rwj Cherry CS2000 | last post by:
hi, i was wondering if you could cast some light on a confusing subject. is there a way which you know of that can search through html documents and extract selected information, and display that...
9
by: florent | last post by:
I'm trying to parse html documents from the web, using the HTMLParser class of the HTMLParser module (python 2.3), but some web documents are not fully valids. When the parser finds an invalid tag,...
2
by: Steve | last post by:
I was looking in the Samples folder for MS Office10 and saw the following files: Analyze sales.htm Employees.htm Review Orders.htm Review Products.htm Sales.htm Where are these files used...
1
by: Mitchell Vincent | last post by:
I've had this trouble in every language I've tried for Windows. Apparently the problem is with the underlying controls or something.. When I loop through and use a hidden web gadget to load and...
2
by: news.ntlworld.com | last post by:
How do I print HTML documents using vb.NET Cheers SteveJ
0
by: Andre Majorel | last post by:
Is there some command-line program for Unix to make all links relative in HTML documents saved in wget -x fashion ? (http://foo.com/a/b.html saved as ./foo.com/a/b.html.) For example, - if...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.