note 57922 deleted from features.http-auth by cmb
| From: | cmb@php.net | Date: | Sun, 13 Oct 2019 08:19:36 +0000 |
| Subject: | note 57922 deleted from features.http-auth by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212643@lists.php.net to get a copy of this message | ||
Note Submitter: oaev at mail dot ru
----
Once more time about PHP through CGI.
Sometimes by some reasons (settings) web-server does not allow to set any environment variables
through .htaccess file, so method offered by bernard dot paques at bigfoot dot com will not work.
Another way to solve this is to set some GET variable:
file .htaccess (it's just my example, maybe you can find better way):
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ([^\s]+).php$ $1.php?BAD_HOSTING=%{HTTP:Authorization}
RewriteCond %{QUERY_STRING} ^(.+)$
RewriteRule ([^\s]+).php $1.php?%1&BAD_HOSTING=%{HTTP:Authorization}
</IfModule>
a part of php file:
<?php
if((empty($_SERVER['PHP_AUTH_USER']) or empty($_SERVER['PHP_AUTH_PW'])) and
isset($_REQUEST['BAD_HOSTING']) and preg_match('/Basic\s+(.*)$/i',
$_REQUEST['BAD_HOSTING'], $matc))
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
explode(':', base64_decode($matc[1]));
?>