Welcome! Log In Create A New Profile

Advanced

Re: encoded url

Francis Daly
May 27, 2015 06:16PM
On Sat, May 23, 2015 at 01:56:32PM -0400, pierob83 wrote:

Hi there,

> I've nginx 1.2.5 and I've an issue about encoded URLs.

I've not tested this on 1.2.5; but the concept should remain the same.

> Is there a way to make nginx accepts URL like the following:
>
> http://www.mywebsite.com/image.php%3Fid%3D12345
>
> as equivalent of the following?
>
> http://www.mywebsite.com/image.php?id=12345

nginx won't directly accept the two as equivalent, because they are not,
in important ways.

There are two approaches you can take.

* redirect the client to the correct url, and let them request that

* proxy_pass the correct url back into the same nginx instance

I do not know the full correct nginx syntax; but if you are happy that
there will not be other encoded characters in the request that must remain
encoded for it to be a valid url, you could try matching on the encoded
? in the request, and using the unencoded version in the next step.

That is:

location ~ \? { return 301 $uri; }

or

location ~ \? {
proxy_pass http://[your bit here]$uri;
proxy_set_header Host $host;
}

where [your bit here] is an ip:port that corresponds to this server's
"listen" directive, and the proxy_set_header bit is to ensure that
this server's server_name matches (and the right thing is used in any
response headers).

Good luck with it,

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

encoded url

pierob83 May 23, 2015 01:56PM

Re: encoded url

J.J J May 23, 2015 08:10PM

Re: encoded url

Francis Daly May 27, 2015 06:16PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 277
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready