Tuesday, December 1, 2009

Apache 2.2 mime_magic_module and PHP scripts

The task: force Apache to handle PHP scripts without any file extensions.
Apache is able to determine MIME of file in two ways:
  1. Using mime_module by extension
  2. Using mime_magic_module by the first several bytes of file
I have investigated the second way.

In order to switch on this module you need:
  • Have the installed module mod_mime_magic.so into modules
  • Add LoadModule mime_magic_module modules/mod_mime_magic.so into httpd.conf
  • Specify its config file MimeMagicFile conf/magic info httpd.conf
  • Add necessary types to the magic file

I have tried to add the next line:
0 string \<?php application/x-httpd-php

as well as:

0 string \<?xml text/xml

But unfortunately I should note, that my variant doesn't work, although the variant concerning XML also doesn't work.

I'm searching a mistake...

No comments:

Post a Comment