By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,961 Members | 1,333 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,961 IT Pros & Developers. It's quick & easy.

Getting Apache content types

P: n/a
Hi All,

Is there a way in PHP to know what all the content-types that Apache knows
about are? Basically, what I want to be able to do is look at an extension,
and then know what content-type Apache would send by default it that file
was requested via HTTP.

Is there a way to do this?

-Josh
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Joshua Beall wrote:
Is there a way in PHP to know what all the content-types that Apache knows
about are? Basically, what I want to be able to do is look at an extension,
and then know what content-type Apache would send by default it that file
was requested via HTTP.

Is there a way to do this?


Maybe this?
http://www.php.net/mime_content_type

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #2

P: n/a
"Pedro Graca" <he****@dodgeit.com> wrote in message
news:sl*******************@ID-203069.user.uni-berlin.de...
Joshua Beall wrote:
Is there a way in PHP to know what all the content-types that Apache
knows
about are? Basically, what I want to be able to do is look at an
extension,
and then know what content-type Apache would send by default it that file
was requested via HTTP.

Is there a way to do this?


Maybe this?
http://www.php.net/mime_content_type


This appears to get it from a file, called "magic.mime"

This might be what I wind up doing, but I was hoping to get something that
had a 1-to-1 correspondence with how Apache was setup. Unless Apache also
uses magic.mime?
Jul 17 '05 #3

P: n/a
Joshua Beall wrote:
"Pedro Graca" <he****@dodgeit.com> wrote in message
news:sl*******************@ID-203069.user.uni-berlin.de...
Joshua Beall wrote:
Is there a way in PHP to know what all the content-types that Apache
knows about are?
Maybe this?
http://www.php.net/mime_content_type


This appears to get it from a file, called "magic.mime"


Oops ...
http://www.php.net/manual/en/ref.mime-magic.php
"This extension has been deprecated ..."
This might be what I wind up doing, but I was hoping to get something that
had a 1-to-1 correspondence with how Apache was setup. Unless Apache also
uses magic.mime?


It appears that Apache falls back on magic.mime if it can't determine
the file type with the mod_mime module.

http://httpd.apache.org/docs/mod/mod_mime.html
http://httpd.apache.org/docs/mod/mod_mime_magic.html

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #4

P: n/a
I'm not sure what Apache uses, but there's a PHP function 'mime_content_type'
which MAY take infos from the same source. Probably this depends on system
platform on which Apache works.

Hilarion
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.