[英]mod_rewrite causes apache to crash with Rewritemap prg directive
[英]Apache RewriteMap prg using fopen('php://stdin', 'r') not working over HTTPS
我已經使用調用 php 腳本的prg
設置了 RewriteMap,如下所示:
#!/usr/local/bin/php
<?php
/* DB query generates $map */
$stdout = fopen('php://stdout', 'w');
$stdin = fopen('php://stdin', 'r');
stream_set_write_buffer($stdout, 0);
while(!feof($stdin)):
$input = fgets($stdin);
fputs($stdout, (array_key_exists($input,$map) ? $map[$input] : 'NULL') . "\n");
endwhile;
?>
然后 .htaccess 將 output 放入環境變量 MAPTO 中,如下所示:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ - [E=MAPTO:${mymap:%1}]
RewriteCond %{ENV:MAPTO} !=""
RewriteRule ^.*$ http://myproxiedcontent.com/%{ENV:MAPTO}/$0 [P,NC]
</IfModule>
它在 HTTP 上正常工作,但在 HTTPS 上沒有返回任何輸入。
我正在使用 Apache 2.4、PHP 7.2 並確認已安裝 OpenSSL。
這里會發生什么?
好吧,我相信我明白了。 我認為這個問題主要與我使用的事實有關 WHM ,它以極其復雜的方式處理 Apache 配置。
我不得不在 httpd.conf 文件中搜索我的 vhost 配置設置。 在這些設置的底部 - 正在配置 SSL - 是一條評論,表明與此 vhost 相關的設置應添加到:
/etc/apache2/conf.d/userdata/ssl/2_4/{USERNAME}/{DOMAIN}.{TLD}
我將我的 RewriteMap 設置放在這里,現在可以正常工作了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.