Answer the question
In order to leave comments, you need to log in
NginX: rewrite or return?
When setting up the NginX server, we all add rules for the URL output we need: output only HTTPS and no WWW, for example.
This is done in two ways:
1) Return:
return 301 https://www.domain.com$request_uri;
return 301 $scheme://domain.com$request_uri;
rewrite ^(.*) https://$host$1 permanent;
rewrite ^ https://$host$request_uri? permanent;
return 302 https://$host$uri;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question