403 显示与 WWW [Nginx]

403 Display with WWW [Nginx]

我只能使用此域名访问网站:

https://example.com [Working]

那是我可以访问它 但是 如果我添加 www;我得到 403 屏幕。

这是我的 Nginx 配置文件。文件:

server {
    listen          80;
    server_name     domain.com;
    rewrite_log     on;

    client_max_body_size 1000M;
    root            /usr/share/nginx/html;
    index           index.php index.html index.htm;

    location / {
        if (!-e $request_filename){
            rewrite ^/(.+)/(.+)$ /index.php?id=&cmd= last; 
            rewrite ^/(.+)$ /index.php?id= last; 
        }
    }


    location ~* \.php$ { 
            fastcgi_pass                    unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_index                   index.php;
            fastcgi_split_path_info         ^(.+\.php)(.*)$;
            include                         /etc/nginx/fastcgi_params;
            fastcgi_param                   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }


}

我自己找到了答案。其实答案很简单。

server_name domain.com; server_name domain.com www.domain.com;

所以我要解决这个问题。