2

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 http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond 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

1 Answer 1

3
+50

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
</Location> 
2
  • 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, 2011 at 21:44
  • Rewriting may require an a2enmod rewrite, so it's no more or less workable on principle.
    – crb
    Apr 13, 2011 at 11:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .