I have this problem that I can't solve. I have a nginx server that I have to make a redirect of this type.
http://midomain.com/xxxx/xxxx/ http://wikipedia.com/xx --> http://midomain.com/yyyy
As I have two urls with a space, there is no way to make it work.
I have tried multiple ways.
rewrite ^/xxxx/xxxx/\ http://wikipedia.com/xx http://midomain.com/yyyy permanent;
rewrite "^/xxxx/xxxx/\ http://wikipedia.com/xx" http://midomain.com/yyyy permanent;
rewrite ^/xxxx/xxxx/ http://wikipedia.com/xx http://midomain.com/yyyy permanent;
rewrite "^/xxxx/xxxx/ http://wikipedia.com/xx" http://midomain.com/yyyy permanent;
rewrite ^/xxxx/xxxx/\ http://wikipedia.com/xx/$ http://midomain.com/yyyy permanent;
rewrite "^/xxxx/xxxx/\ http://wikipedia.com/xx/$" http://midomain.com/yyyy permanent;
rewrite ^/xxxx/xxxx/ http://wikipedia.com/xx/$ http://midomain.com/yyyy permanent;
I don't know if I'm doing something wrong.
CodePudding user response:
Nginx normalises the URI before processing it through rewrite
. The
is resolved to a literal space character and consecutive /
characters are replace by a single /
. It's that last point that's causing you problems.
For example:
rewrite "^/xxxx/xxxx/ http:/wikipedia\.com/xx$" http://midomain.com/yyyy permanent;