Encode url

Hi,

I’m writing my first nginx module. The module at some point uses the
“Location” header to redirect to user to a landing page. The redirected
url has many arguments which could potentially contain spaces, slashes
or any other non-alphabetic chars.

Is there a function that’ll escape then and convert them to %20, %2f and
so on?

Thanks.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,153434,153434#msg-153434

Hi,

I really need the same for rewrite and variables like $http_referer or
$request_uri.

There were several questions regarding that in the past, but I can’t
find a solution.

An example:
[code]

url rewriting

location ~ \.htm$ {
  rewrite ^/([a-z0-9_]+)\.htm$ /$1.php?uri=$request_uri break;
  proxy_next_upstream error timeout http_500 http_503 http_404

invalid_header;
proxy_pass http://backend;
}
[/code]

In some rules $request_uri contains arguments with ampersand and as it
isn’t escaped, those won’t be part of the “uri”-var.

I really like to have a function like url_encode() or something similar
to str_replace().

regards,
Marc

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,153434,167140#msg-167140

Same problem here:
http://forum.nginx.org/read.php?2,34381

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,153434,169019#msg-169019

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs