I have a problem similar to this: http://www.tek-tips.com/viewthread.cfm?qid=1144803
I'm trying to grant access, if specific RewriteRule
triggered. Setting a var using [E]
flag, but the var seems unset when the subsequent authorization step is performed.
Unconditional SetEnv let_me_in
doesn't work either, but surprisingly, SetEnvIf
does work.
<Directory "/srv/http">
Require env let_me_in
</Directory>
<Directory "/srv/http/html">
RewriteRule ^hello/dostuff/(.*)$ /cgi-bin/hello.sh?anon=1&x=$1 [B,E=let_me_in]
</Directory>
<Location /hello/>
Require all granted
</Location>
SetEnvIf Request_URI "(^.*$)" RURI=$1
ErrorLog "/var/log/httpd/error_log"
LogLevel debug
ErrorLogFormat "[%t] %M URI: '%{RURI}e' let_me_in: '%{let_me_in}e'"
[Thu Oct 22 14:27:29 2015] AH01626: authorization result of Require all granted: granted URI: '/hello/dostuff/foobar' let_me_in:
[Thu Oct 22 14:27:29 2015] AH01626: authorization result of <RequireAny>: granted URI: '/hello/dostuff/foobar' let_me_in:
[Thu Oct 22 14:27:29 2015] AH01626: authorization result of Require env let_me_in: denied URI: '/cgi-bin/hello.sh' let_me_in:
[Thu Oct 22 14:27:29 2015] AH01626: authorization result of <RequireAny>: denied URI: '/cgi-bin/hello.sh' let_me_in:
[Thu Oct 22 14:27:29 2015] AH01630: client denied by server configuration: /srv/http/cgi-bin/hello.sh URI: '/cgi-bin/hello.sh' let_me_in:
Seen the table at the bottom: http://www.onlinesmartketer.com/2010/05/27/apache-environment-variables-visibility-with-setenv-setenvif-and-rewriterule-directives/
Tried to add:
SetEnvIf Request_URI "^/hello/dostuff/(.*)$" hello_params=$1
The var is definitely set at the beginning, but RewriteRule
unsets it!
[Thu Oct 22 15:23:12 2015] AH01626: authorization result of Require all granted: granted URI: '/hello/dostuff/fooba' hello_params: 'fooba'
[Thu Oct 22 15:23:12 2015] AH01626: authorization result of <RequireAny>: granted URI: '/hello/dostuff/fooba' hello_params: 'fooba'
[Thu Oct 22 15:23:12 2015] AH01626: authorization result of Require env hello_params: denied URI: '/cgi-bin/hello.sh' hello_params:
[Thu Oct 22 15:23:12 2015] AH01626: authorization result of <RequireAny>: denied URI: '/cgi-bin/hello.sh' hello_params:
[Thu Oct 22 15:23:12 2015] AH01630: client denied by server configuration: /srv/http/cgi-bin/hello.sh URI: '/cgi-bin/hello.sh' hello_params: