nginx configuration access xx.com Jump www.xx.com

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.

Guess you like

Origin www.cnblogs.com/uglyliu/p/11777407.html