Nginx implements permanent (301) temporary (302) redirection
Popular Science:
301 permanent redirect: When a user or search engine sends a browser request to the website server, one of the status codes in the header information returned by the server in the HTTP data stream indicates that the webpage is permanently transferred to another address.
302 temporary jump is also a status code, meaning that it is temporarily redirected to another URL.
The main difference between the two is that, in a single sentence, 302 is easily regarded as spam by search engines, and 301 won't.
Official nginx rewrite documentation:
Nginx is slightly different from apache rules. this code redirects lanyingblog.com to www.lanyingblog.com to avoid distribution of search engine weights.
if ($host != 'www.lanyingblog.com') { rewrite ^/(.*)$ http://www.lanyingblog.com/$1 permanent;}
Add it to the conf configuration file. I usually put it together with the pseudo-static configuration. In the code, if it is not www.lanyingblog.com, it will automatically jump to www.lanyingblog.com. permanent indicates that 301 is a permanent jump, and 302 is a temporary jump if it is changed to redirect.