欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

CI 在nginx中出现404错误的解决方式

发布时间:2025/6/17 编程问答 49 豆豆
生活随笔 收集整理的这篇文章主要介绍了 CI 在nginx中出现404错误的解决方式 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

因为你的nginx配置的是截取.php文件后缀的访问转发到PHP-CGI,而index.php和index.php/是不一样的。。 你在nginx里面写一句:

if (!-e $request_filename) {rewrite ^.*$ /index.php last;}
//出现的问题 用这个解决了,

 

NGINX 默认不支持 PATH_INFO 模式,需要修改NGINX配置 让NGINX 来解析 index.php/controller/f 这种模式 具体配置:#CI server {listen 80;server_name www.ci.com;index index.php index.html index.htm;root "/servers/apps/CI";location ~ \.php{fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;##########################################pathinfo 模式set $path_info "";set $real_script_name $fastcgi_script_name;if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$"){set $real_script_name $1;set $path_info $2;}include fastcgi.conf;fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;fastcgi_param SCRIPT_NAME $real_script_name;fastcgi_param PATH_INFO $path_info;##########################################nginx支持pathinfo 模式的重点 } }

 

转载于:https://www.cnblogs.com/hubing/p/3984002.html

总结

以上是生活随笔为你收集整理的CI 在nginx中出现404错误的解决方式的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。