【问题标题】:when we redirecting the page it showing 404 Page Not Found The page you requested was not found in codeigniter using ngnix当我们重定向页面时,它显示 404 Page Not Found The page you requested is not found in codeigniter using nginx
【发布时间】:2023-03-26 21:00:01
【问题描述】:

当我们重定向页面时,它显示 404 Page Not Found The page you request was not found on codeigniter using ngnix

【问题讨论】:

  • 这表示您的网址不可用。请通过这个stackoverflow.com/help/how-to-ask
  • 您的控制器名称是什么?给我看看你的redirect 行的代码。
  • 如果使用nginx,则不需要.htaccess标签。

标签: php .htaccess codeigniter


【解决方案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;
        }
}

如果与nginx.conf在同一文件夹中没有fastcgi.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;

就是这样!

【讨论】:

  • 嗨,deniz,感谢您的回复,在哪里创建文件 nginx.conf 和 fastcgi.conf 以及应该在哪里包含您提供的上述代码
  • 你不需要创建 nginx.conf 文件,它已经存在了。只需通过 ssh 连接您的服务器并输入 nginx -t 并按 Enter。你会看到 nginx.conf 路径。
  • 我说的你做到了吗?如果成功了,请重启nginx再试一次。
  • 是的,我重新启动它,它再次显示错误错误 404 Not Found nginx/1.4.6 (Ubuntu)...
  • 你能把nginx -t发给我输出吗?
猜你喜欢
  • 2020-12-05
  • 2011-11-09
  • 1970-01-01
  • 2016-09-10
  • 2021-12-21
  • 1970-01-01
  • 2013-10-07
  • 1970-01-01
  • 2018-04-18
相关资源
最近更新 更多