Page 1 of 1

PHP MIME Type

Posted: Wed Mar 12, 2003 3:46 pm
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.

Posted: Wed Mar 12, 2003 4:36 pm
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.

Posted: Thu Mar 13, 2003 12:40 am
by net7
Thats cool, you could pull alot of tricks with those... the smart 'gif'.

Keep getting misconfiguration

Posted: Thu Mar 13, 2003 11:26 am
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?

Posted: Thu Mar 13, 2003 2:46 pm
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.

Posted: Thu Mar 13, 2003 4:57 pm
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

Posted: Thu Mar 13, 2003 5:02 pm
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