PHP MIME Type

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
EricS
Forum Contributor
Posts: 183
Joined: Thu Jul 11, 2002 12:02 am
Location: Atlanta, Ga

PHP MIME Type

Post by EricS »

If I was going to change the handling of an extension using .htaccess in a directory so that PHP would handle it, would I use text/html as the mime type.

Example:

text/html .jpg

This would be to force apache to threat any files with extension .jpg as a php file.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Is this a question? ;)
you registered (probably) application/x-httpd-php to be handled via php.
AddType application/x-httpd-php .php
So, e.g.

Code: Select all

AddType application/x-httpd-php .jpg
and .gifs (edit: :oops: .jpgs of course) will be handled by php.
Last edited by volka on Thu Mar 13, 2003 1:56 am, edited 1 time in total.
net7
Forum Commoner
Posts: 31
Joined: Wed Mar 12, 2003 1:27 pm

Post by net7 »

Thats cool, you could pull alot of tricks with those... the smart 'gif'.
EricS
Forum Contributor
Posts: 183
Joined: Thu Jul 11, 2002 12:02 am
Location: Atlanta, Ga

Keep getting misconfiguration

Post by EricS »

I've tried all of the following and I keep getting a misconfiguration error.

Code: Select all

<Files test.gif> 
   ForceType application/x-httpd-php 
</Files>

and

ForceType application/x-httpd-php

and

AddType application/x-httpd-php .gif
Does anyone see a problem with this?

Also, how do I check what MIME Type PHP is set to on the server?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

http://httpd.apache.org/docs/mod/mod_mime.html#addtype
AddType directive
Override: FileInfo
Module: mod_mime
http://httpd.apache.org/docs/mod/mod_mime.html#forcetype
ForceType directive
Module: mod_mime
therefor you need mod_mime and maybe AllowOverride FileInfo or more.
net7
Forum Commoner
Posts: 31
Joined: Wed Mar 12, 2003 1:27 pm

Post by net7 »

What are you putting that into?

I didn't get any of those to work in my .htaccess file but my

/etc/httpd/conf.d/php.conf

Had some lines kind of like that. Try puting this into the file

Code: Select all

<Files *.gif> //or you could do test.gif
  SetOutputFilter PHP
  SetInputFilter PHP
  LimitRequestBody 524288
</Files>

=D
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I have a directory test on my personal (break-down) server, where I can play with all those settings. Currently the .htaccess contains
php_value session.gc_probability 100
php_value session.gc_maxlifetime 60
php_flag always_populate_raw_post_data On
AddType application/x-httpd-php .gif
but (since I stopped to fear my own curiosity long ago ;) ) httpd.conf contains AllowOverride All for the DocumentRoot-entry
Post Reply