Second, the configuration in which nginx rewrite rules. Open Nginx.conf find server configuration file section: [The following is my server configuration section]
IP address is disabled access
server{
listen 80 default_server;
server_name _;
return 403;
}
IP address is disabled access
server {
listen 80;
server_name www.xxx.com xxx.com;
if ($host != 'www.xxx.com') {
rewrite ^/(.*)$ http://www.xxx.com/$1 permanent;
}
}
So that direct users to directly access xxx.com jump www.xxx.com. That let the domain name without the www domain name to jump to the www.