How to do this rewrite in nginx?

I want to make a redirect, I read that with nginx you can use a variable(Directive) $request_uri, tried to do so:
 if($request_uri != robots.txt){
 rewrite ^(.*)$1 permanent;

Tell me, how in this context to use request or how best to implement such a redirection? Thank you!
July 2nd 19 at 18:12
1 answer
July 2nd 19 at 18:14
Likely to be something like this:
if ($request_uri ~ "^/robots.txt") {
# or
# if ($request_uri != "robots.txt") {
 rewrite ^(.*)$1 permanent;
Thanks, man. I thought that might be worth a line to separate the quotes, so the case did not come to this, because the rest of the config did not find anything hinting at such a need.
I chose if ($request_uri != "robots.txt"), it is pleasant is perceived by the eye. - Juana95 commented on July 2nd 19 at 18:17

Find more questions by tags Nginxrobots.txt