HTTP Authentication + PHP + Apache Server API CGI/FastCGI

804 Views Asked by At

I have a system implemented in php that has been working for years and uses head HTTP_AUTHORIZATION for logging.

Now the hosting provider made changes to the server and the server does not receive the header.

Searching here for information I find that it has to do with the new server api on the server: CGI/FastCGI.

I have the following htaccess that worked before the change (and now it doesn't have the header):

RewriteBase /
    Options FollowSymLinks
    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{HTTP:Authorization} ^(.*)
        RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
        
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?/$1 [L]
    </IfModule>
    
    <IfModule !mod_rewrite.c>
        ErrorDocument 404 /index.php
    </IfModule>

And making these changes according to recommendations does not work either:

RewriteBase /
    Options FollowSymLinks
    <IfModule mod_rewrite.c>
        SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
        
        RewriteEngine on
        RewriteCond %{HTTP:Authorization} ^(.*)
        RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
        
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?/$1 [L]
    </IfModule>
    
    <IfModule !mod_rewrite.c>
        ErrorDocument 404 /index.php
    </IfModule>

I also tried this alternative:

RewriteBase /

Options FollowSymLinks
<IfModule mod_rewrite.c>
    CGIPassAuth On
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

Some more details:

PHP Version 5.5.38

Server API CGI/FastCGI

Any ideas what to change to fix them? Thanks

0

There are 0 best solutions below