Monday, 30 July 2018

Apache .htaccess RewriteRule discards config directive

I have the following (simplified) folder/file structure:

/.htaccess
/test.php
/api/web/index.php

And the following directive in apache config:

<IfModule mod_deflate.c>
    <IfModule mod_filter.c>
        SetInputFilter DEFLATE
   </IfModule>
</IfModule>

I am sending a POST request with a gzipped body with the appropiated headers:

POST /test.php HTTP/1.1
Host: 192.168.1.248
Authorization: Bearer ed717c077e4bf81201196011adb457731b24e19d
Content-Type: application/json
Content-Encoding: gzip

And I have the following config for the .htaccess file:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^api/(.*) api/web/index.php/$1 [NC,L]

The issue is, if I post to /test.php, everything works as expected, the body is deflated and I can access de decompressed contents just right.

However if I post to something that gets redirected (/api/ or /api/v1/project) the index.php script does not get the body decompressed.

I think it must be related to the RewriteRule directive ignoring the SetInputFilter directive, but, how can I avoid this situation?

I tried to add the SetInputFilter directive directly in the htaccess without solving the issue (may be it was not in the right place?).

Do you know how can I solve this?



from Apache .htaccess RewriteRule discards config directive

No comments:

Post a Comment