Answer the question
In order to leave comments, you need to log in
How to pass url with & symbols to nginx? from php using X-Accel-Redirect?
Nginx is used to proxy a remote server.
php code:
$url = '/internal_redirect/?url=' .
'domain.com?test=123&test2=234' .
'&protocol=https';
header("X-Accel-Redirect: " . $url);
domain.com?test=123&test2=234. If you leave it as in the example, then additional variables like arg_test2 will simply be passed, etc. If you use urlencode, then nginx does not automatically decode. How to deal with symbols? and & Preferably without installing additional modules. This is real?
location ~* ^/internal_redirect/ {
internal;
set $download_url $arg_protocol://$arg_url;
proxy_pass $download_url;
}
Answer the question
In order to leave comments, you need to log in
First, just add the prefix /internal_redirect/
$url = '/internal_redirect/http://domain.com/?test=123&test2=234';
header("X-Accel-Redirect: " . $url);
location ~ ^/internal_redirect/(?<url>.+) {
internal;
proxy_pass $url$is_args$args;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question