首页 > 解决方案 > 403 显示与 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=$1&cmd=$2 last; 
            rewrite ^/(.+)$ /index.php?id=$1 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;
    }


}

标签: nginxwebhttp-status-code-404

解决方案


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

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

所以我要解决这个问题。


推荐阅读