A client of ours has created a QR code that includes a blank space in the url. How would I write an nginx redirect that dealt with this problem?
A couple of attempts using things like "%20" in the string seem to cause nginx to error or fail the configtest
To be precise the QR code reads like this
http://www.google.com/somestuff /someotherstuf/pagewewant
and I need to re direct it to
http://www.google.com/somestuff/someotherstuf/pagewewant (The re write should show no blank space after somestuff )
Thanks for your time
Question is over two years old, but maybe it'll save someone some headaches.
Word of warning: I am no nginx expert. It's just one the things I tried after finding this unanswered question and it happened to work. It may not be the best way to do that. I would recommend checking the nginx documentation in case one is looking at handling a significantly large amount of such locations.
For the occasional rewrite including spaces I put the path in single quotes:
location '/level_one /landingpage.htm' {
rewrite ^ http://www.foo.bar/level_one/landingpage.htm permanent; }
If for some reason you need to have spaces in the target put that in single quotes as well:
location '/downloads/foo bar.pdf' {
rewrite ^ 'http://www.foo.bar/documents/foo bar.pdf' permanent; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With