Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Parsing a php file with html extension

Reply
Thread Tools

Parsing a php file with html extension

 
 
kayodeok
Guest
Posts: n/a
 
      11-23-2003
Would someone mind clarifying a few points for me:

My webpages in my sig all have the html extension however, I have
one page which should be parsed as php (not yet uploaded).

I do not want to add the php extension preferring to keep the html
extension.

My research on this is quite conflicting:

some Websites such as http://www.spiderpro.com/bu/buphph001.html
asks me to include AddType application/x-httpd-php .php .html in my
..htacess file and put it in every directory I need it for.

Others such as http://www.zend.com/manual/security.hiding.php asks
me to include just AddType application/x-httpd-php .html in my
..htacess file but mentions that I would suffer a performance hit on
my pages.

I am unable to locate the definitive source for these instructions.

Does anyone know where I can locate the source url? Or better
still, explain the difference between

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

and

AddType application/x-httpd-php .html

Thanks

--
Kayode Okeyode
http://www.kayodeok.co.uk/weblog/
 
Reply With Quote
 
 
 
 
Bob Long
Guest
Posts: n/a
 
      11-23-2003
In news:Xns943C6CF40A9D4news4kayode@130.133.1.4,
kayodeok <(E-Mail Removed)> typed:
> Would someone mind clarifying a few points for me:
>
> My webpages in my sig all have the html extension however, I have
> one page which should be parsed as php (not yet uploaded).
>
> I do not want to add the php extension preferring to keep the html
> extension.
>
> My research on this is quite conflicting:
>
> some Websites such as http://www.spiderpro.com/bu/buphph001.html
> asks me to include AddType application/x-httpd-php .php .html in my
> .htacess file and put it in every directory I need it for.
>
> Others such as http://www.zend.com/manual/security.hiding.php asks
> me to include just AddType application/x-httpd-php .html in my
> .htacess file but mentions that I would suffer a performance hit on
> my pages.
>
> I am unable to locate the definitive source for these instructions.
>
> Does anyone know where I can locate the source url? Or better
> still, explain the difference between
>
> AddType application/x-httpd-php .php .html
>
> and
>
> AddType application/x-httpd-php .html
>
> Thanks


It's probably AddHander that you want:

http://httpd.apache.org/docs/mod/mod...tml#addhandler


 
Reply With Quote
 
 
 
 
Bob Long
Guest
Posts: n/a
 
      11-23-2003
In news:Xns943C6CF40A9D4news4kayode@130.133.1.4,
kayodeok <(E-Mail Removed)> typed:
> Would someone mind clarifying a few points for me:
>
> My webpages in my sig all have the html extension however, I have
> one page which should be parsed as php (not yet uploaded).
>
> I do not want to add the php extension preferring to keep the html
> extension.
>
> My research on this is quite conflicting:
>
> some Websites such as http://www.spiderpro.com/bu/buphph001.html
> asks me to include AddType application/x-httpd-php .php .html in my
> .htacess file and put it in every directory I need it for.
>
> Others such as http://www.zend.com/manual/security.hiding.php asks
> me to include just AddType application/x-httpd-php .html in my
> .htacess file but mentions that I would suffer a performance hit on
> my pages.
>
> I am unable to locate the definitive source for these instructions.
>
> Does anyone know where I can locate the source url? Or better
> still, explain the difference between
>
> AddType application/x-httpd-php .php .html
>
> and
>
> AddType application/x-httpd-php .html


The extensions on the end specify which are used. You can have more than
one.
http://httpd.apache.org/docs/mod/mod_mime.html#addtype

Bob Long
(If my other message appears - even though I cancelled it, ignore it. It's
wrong and was sent prematurely.)


 
Reply With Quote
 
Toby A Inkster
Guest
Posts: n/a
 
      11-23-2003
kayodeok wrote:

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


Assuming the server is already set up to parse ".php" files as PHP, then
both are exactly equivalent.

> but mentions that I would suffer a performance hit on
> my pages.


This is because it instructs Apache to parse *all* files with the
extension ".html" as PHP. If you just need the one, then you could use
something like:

<Files myscript.html>
ForceType application/x-httpd-php
</Files>

There is still a *tiny* performance hit -- this is because *any*
".htaccess" files need to be parsed for each and every request from the
containing directory or any of its subdirectories.

To get around that, you may find it useful to do this configuration in the
main httpd.conf file, assuming you have permission.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?page=132

 
Reply With Quote
 
kayodeok
Guest
Posts: n/a
 
      11-23-2003
"Bob Long" <(E-Mail Removed)> wrote in
news:3fc0b98d$0$1756$(E-Mail Removed) u:

>> I am unable to locate the definitive source for these
>> instructions.
>>
>> Does anyone know where I can locate the source url? Or better
>> still, explain the difference between
>>
>> AddType application/x-httpd-php .php .html
>>
>> and
>>
>> AddType application/x-httpd-php .html

>
> The extensions on the end specify which are used. You can have
> more than one.
> http://httpd.apache.org/docs/mod/mod_mime.html#addtype


Thanks
Based on the source document, I was able to construct more accurate
searches to research the document.

Previously, I was searching for "AddType application/x-httpd-php"
which did not return any file from apache.org and I was a bit too
stressed to notice that application/x-httpd-php is a mime type.

Regards

--
Kayode Okeyode
http://www.kayodeok.co.uk/weblog/
 
Reply With Quote
 
Eric B. Bednarz
Guest
Posts: n/a
 
      11-23-2003
kayodeok <(E-Mail Removed)> writes:

> "Bob Long" <(E-Mail Removed)> wrote:


>> http://httpd.apache.org/docs/mod/mod_mime.html#addtype


> Previously, I was searching for "AddType application/x-httpd-php"
> which did not return any file from apache.org


Incidentally, that's a good thing, because it's a popular but fatal
misconfiguration of the server; leave AddType alone and locate the
AddHandler directive on the same page of the documentation.

For more info, consult your old friend:

<http://www.google.com/search?q=406+http+accept+addtype>


--
| ) Eric Bednarz
-(
| ) http://bednarz.nl/
 
Reply With Quote
 
kayodeok
Guest
Posts: n/a
 
      11-23-2003
Toby A Inkster <(E-Mail Removed)> wrote in
news(E-Mail Removed):

> kayodeok wrote:
>
>> AddType application/x-httpd-php .php .html
>> AddType application/x-httpd-php .html

>
> Assuming the server is already set up to parse ".php" files as
> PHP, then both are exactly equivalent.
>
>> but mentions that I would suffer a performance hit on
>> my pages.

>
> This is because it instructs Apache to parse *all* files with
> the extension ".html" as PHP. If you just need the one, then you
> could use something like:
>
> <Files myscript.html>
> ForceType application/x-httpd-php
> </Files>
>
> There is still a *tiny* performance hit -- this is because *any*
> ".htaccess" files need to be parsed for each and every request
> from the containing directory or any of its subdirectories.
>

Thanks, I am considering changing some stuff around in my site and
moving the php files (currently there is only one file) to a new
directory since they will all have the same structure. I am still
working out the details in my head.

--
Kayode Okeyode
http://www.kayodeok.co.uk/weblog/
 
Reply With Quote
 
kayodeok
Guest
Posts: n/a
 
      11-23-2003
Eric B. Bednarz <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> kayodeok <(E-Mail Removed)> writes:
>
>> "Bob Long" <(E-Mail Removed)> wrote:

>
>>> http://httpd.apache.org/docs/mod/mod_mime.html#addtype

>
>> Previously, I was searching for "AddType
>> application/x-httpd-php" which did not return any file from
>> apache.org

>
> Incidentally, that's a good thing, because it's a popular but
> fatal misconfiguration of the server; leave AddType alone and
> locate the AddHandler directive on the same page of the
> documentation.
>
> For more info, consult your old friend:
>
> <http://www.google.com/search?q=406+http+accept+addtype>


Thanks, I will look into the AddHandler directive; actually I think
I ought to fully investigate these directives before playing around
with them...thanks for the pointer.

--
Kayode Okeyode
http://www.kayodeok.co.uk/weblog/
 
Reply With Quote
 
David Graham
Guest
Posts: n/a
 
      11-24-2003
> <Files myscript.html>
> ForceType application/x-httpd-php
> </Files>
>
> There is still a *tiny* performance hit -- this is because *any*
> ".htaccess" files need to be parsed for each and every request from the
> containing directory or any of its subdirectories.
>

Hi Toby
I am thinking of using this because I just want my index page to be parsed
as php. I want the .html extension to remain on the index page because that
is what people are used to typing etc. so, to make sure I understand you,
what I do is put:

<Files index.html>
ForceType application/x-httpd-php
</Files>

exactly as above on 3 seperate lines in my .htaccess file, I assume it is
necessary for the .htaccess file to be in the same directory as the index
page. The extra hit due to the server reading this small text file would not
be that significant - or am i mistaken?

Alternative solution:
"To get around that, you may find it useful to do this configuration in the
main httpd.conf file, assuming you have permission."

I think I would mess things up good if I try your suggestion of altering the
httpd.conf file

Loads of questions follow (understand if you think a person with limited
knowledge would never be able to do this)

1. I would like to know how to get at this file
2. I have a remote host ISP. How do I know if I have permission to alter it?
3. Would I alter it by adding the 3 lines above?

thanks
David





 
Reply With Quote
 
Toby A Inkster
Guest
Posts: n/a
 
      11-24-2003
David Graham wrote:
> I am thinking of using this because I just want my index page to be parsed
> as php. I want the .html extension to remain on the index page because that
> is what people are used to typing etc. so, to make sure I understand you,
> what I do is put:
>
> <Files index.html>
> ForceType application/x-httpd-php
> </Files>
>
> exactly as above on 3 seperate lines in my .htaccess file


Yes, that looks about right. For example, this PHP file:

http://www.goddamn.co.uk/tobyink/scr.../testfile.html

The source code is here:

http://www.goddamn.co.uk/tobyink/scr...r/testfile.txt

> I assume it is
> necessary for the .htaccess file to be in the same directory as the index
> page.


Not really, but it is probably easiest if it is. For example, mine is here:

http://www.goddamn.co.uk/tobyink/scr...dler/.htaccess

Although you can't see it (permission denied) so here is a copy:

http://www.goddamn.co.uk/tobyink/scr...r/htaccess.txt

However, if I wanted to put it here:

http://www.goddamn.co.uk/tobyink/scratch/.htaccess

that would be OK! But I'd have to change the first line to:

<Files "sethandler/testfile.html">

I think so anyway. I've not tried it. Best to be safe and stick with the
same directory.

> The extra hit due to the server reading this small text file would not
> be that significant - or am i mistaken?


It is small, but as I say, the .htaccess file has to be processed for each
request, not only to (in my example) "testfile.html" but to any file in
the whole "sethandler/" directory, and any subdirectories that
"sethandler/" had.

> 1. I would like to know how to get at this file


It's usually kept somewhere in "/etc/httpd/conf/" on Linux and UNIX
servers.

> 2. I have a remote host ISP. How do I know if I have permission to
> alter it?


By asking Tech support. If you have a cheap host or a shared server, you
probably won't be able to edit it. If you're on a dedicated host, you
might be able to. If you're on a shared host but you're paying them a lot
of money, they might make the changes for you so long as they are
reasonable and you ask nicely.

> 3. Would I alter it by adding the 3 lines above?


More or less, but it would probably have to be inside a bigger <Directory>
block:

<Directory "/path/to/the/directory/">
<Files index.html>
ForceType application/x-httpd-php
</Files>
</Directory>

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?page=132

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Non-correcting library for parsing/modifying broken HTML/PHP files? Markus Fischer Ruby 2 04-05-2011 01:27 PM
PHP Training Institute In Delhi, Live Projects on PHP. Short TermPHP Courses, PHP Scripts, PHP Training with Live Projects. Rajive Narain Java 0 09-18-2009 10:47 AM
Ruby equivalence for php include("file.php"); Miquel Oliete Ruby 4 03-07-2008 06:33 PM
Validate your html forms with javascript and php with a simple php class __ Javascript 1 10-02-2007 11:06 AM
How to convert a .txt file extension to a .xls file extension? Steve ASP .Net 3 08-25-2006 05:43 PM



Advertisments