Home > Software design >  Apache "RequestHeader set" does not work on header with underscore
Apache "RequestHeader set" does not work on header with underscore

Time:11-07

In a legacy application, we have to use a http header that looks like this "Drupal_NNI". Since we just migrated to a newest version of Apache, this header is not even recognized, so I found a trick to still use the underscore but change it with a dash when caught by apache :

RequestHeader set drupal-nni "expr=%{req:Drupal_NNI}"

My issue is that it works well in local on my Xampp 3.3, but in the server with apache 2.4.46 it does not work anymore although it used to work when I've set this for the first time.

The header "Drupal_NNI" is not changed into "drupal-nni", and this issue happens only when a header contains an underscore, I can reset any other header. This works for example :

RequestHeader set doe "expr=%{req:john}"

CodePudding user response:

I found the solution, thanks to this post : Apache - Convert underscores to dashes in headers.

I just had to add this line right before mine :

SetEnvIfNoCase ^Accept.Encoding$ ^(.*)$ fix_accept_encoding=$1
  • Related