当我们重定向页面时,它显示404页面未找到您使用ngnix在codeigniter中找不到您请求的页面

时间:2016-05-05 09:25:32

标签: php .htaccess codeigniter

当我们重定向页面时显示404页面未找到您使用ngnix在codeigniter上找不到您请求的页面

404 Page Not Found

1 个答案:

答案 0 :(得分:1)

首先,通过ssh连接您的服务器并发送以下命令:

nginx -t

它将测试你的nginx配置文件并显示配置文件的路径。然后打开您的配置文件并在html {}部分(include /etc/nginx/conf.d/*.conf;行之前)添加这些文件:

server {
        server_name yourdomain.tld;

        root /your/codeigniters/full/path;
        index index.html index.php;

        # set expiration of assets to MAX for caching
        location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
                expires max;
                log_not_found off;
        }

        location / {
                # Check if a file or directory index file exists, else route it to index.php.
                try_files $uri $uri/ /index.php;
        }

        location ~* \.php$ {
                fastcgi_pass 127.0.0.1:9000;
                include fastcgi.conf;
        }
}

如果fastcgi.conf与同一文件夹中没有nginx.conf,请创建一个并添加以下行:

#fastcgi.conf
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

这就是全部!