Good day time. Set up a redirect from a domain name from www to a domain name without www.

server { listen 80; server_name www.someserver.ru; rewrite ^/(.*) http://someserver.ru$1 permanent; } 

I added the same block to the configuration file, but with a Russian domain name:

 server { listen 80; server_name мой-сервер.рф; rewrite ^/(.*) http://someserver.ru$1 permanent; } 

The redirect from the domain name www.someserver.ru works, and from the domain name my-server. Rf goes to the nginx test page. I also tried using the Unicode line instead of my-server.rf in the config, but the result is the same. How can I fix the problem?
Regards, maxspb.

  • And what do the logs say? Surely there you can find which server_name nginx saw at the request. - yeputons

1 answer 1

Most likely, the replacement of the domain name with his own in punycode will help you. This is the standard for converting domain names from arbitrary characters into domains from Latin characters. For example:

 server { listen 80; server_name xn----jtbanomrbf6a.xn--p1ai; rewrite ^/(.*) http://someserver.ru$1 permanent; } 

The fact is that the domain name system does not initially support non-Latin characters, so punycode was added - this is a crutch from user applications, which out-of-the-box converts the name in Unicode to something in Latin.

  • I tried this option, unfortunately it does not work - maxspb89
  • So, I inserted a puny jamb. Converted using the site and it all worked, thanks. - maxspb89
  • @ maxspb89 Please. Mark then, please, answer as true. I think the question and answer may be useful to others. - yeputons