Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was trying to prevent PHP from parsing POST requests. It does automatically when it sees the according MIME type. For that I was considering following RewriteRule hack:

RewriteCond %{HTTP:Content-Type} ^(multipart/form-data\s*;.*)$   
RewriteRule mime.php - [E=CONTENT_TYPE:no/parsing;old=%1]

But the CGI environment still contains the original [CONTENT_TYPE] => multipart/form..

  • I could set e.g. ALT_CONTENT_TYPE troublefree, but that's no use to me, because PHP still acts on the original then.
  • Likewise changing the case [E=ContEnt_Type] will not remove the old header value, it just changes the case really.
  • Is the CONTENT_TYPE env var constructed at a later stage? Because I also had trouble accessing it as just %{CONTENT_TYPE}. But on a second look, the docs didn't mention it anyway.

Is there another way to override this CGI variable?

local testserver:

 Server version: Apache/2.2.14 (Ubuntu)
 mod_php, not fastcgi
 Linux snig 2.6.32-29-generic #58-Ubuntu SMP, 2011 x86_64 GNU/Linux
share|improve this question
up vote 4 down vote accepted

This answer suggests an Apache solution:

<Location "/backend/XXX.php">
    SetEnvIf Content-Type ^(multipart/form-data)(.*) NEW_CONTENT_TYPE=multipart/form-data-alternate$2 OLD_CONTENT_TYPE=$1$2
    RequestHeader set Content-Type %{NEW_CONTENT_TYPE}e env=NEW_CONTENT_TYPE
share|improve this answer
That works. Needs an a2enmod headers though. So maybe not workable on all servers. (But the existence of that specific module makes a simpler solution unlikely.) – mario Apr 12 '11 at 21:44
Rewriting may require an a2enmod rewrite, so it's no more or less workable on principle. – crb Apr 13 '11 at 11:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.