Apache2 – mod_rewrite:RequestHeader和环境variables
我尝试获取请求参数“授权”的值,并将其存储在请求的标题“授权”中。 第一个重写规则工作正常。 在第二个重写规则中,$ 2的值似乎并不存储在环境variables中。 结果请求头“授权”是空的。 任何想法 ? 谢谢。 <VirtualHost *:8010> RewriteLog "/var/apache2/logs/rewrite.log" RewriteLogLevel 9 RewriteEngine On RewriteRule ^/(.*)&authorization=@(.*)@(.*) http://<ip>:<port>/$1&authorization=@$2@$3 [L,P] RewriteRule ^/(.*)&authorization=@(.*)@(.*) – [E=AUTHORIZATION:$2,NE] RequestHeader add "Authorization" "%{AUTHORIZATION}e" </VirtualHost> 我需要处理几个案例,因为有时参数在path中,而他们在查询中。 取决于用户。 这最后一个案件失败。 AUTHORIZATION的标题值看起来是空的。 # if the query string includes the authorization parameter RewriteCond %{QUERY_STRING} ^(.*)authorization=@(.*)@(.*)$ # keep the value of the parameter in the AUTHORIZATION […]