简体   繁体   English

访问控制器时,nginx上Codeigniter发生404错误

[英]404 errors with Codeigniter on nginx when accessing controller

I'm using Codeigniter for my website, the root website works just fine which has a landing page, however I have a development section located /var/www/domain.com/www/dev/ which /var/www/domain.com/www/ is the root (landing page is stored there). 我用笨,我的网站,网站的根工作得很好,它有一个登陆页面,但是我有一个开发部位于/var/www/domain.com/www/dev//var/www/domain.com/www/是根(登陆页面存储在那里)。

Now, when I go to domain.com/dev , my codeigniter website works fine, but when I load an controller, eg domain.com/index.php/search it gives me an 404 error. 现在,当我访问domain.com/dev ,我的codeigniter网站工作正常,但是当我加载控制器时,例如domain.com/index.php/search它给我一个404错误。

In the error logs of domain.com it shows this: domain.com的错误日志中显示:

2011/10/02 02:03:37 [error] 17042#0: *568 open() "/var/www/domain.com/www/dev/index.php/search" failed (20: Not a directory), client: xx.xx.xx.xx, server: domain.com, request: "GET /dev/$

Now I have no complete idea why it's doing this and how to resolve this issue. 现在我还没有完全了解它为什么这样做以及如何解决这个问题。 How can I stop this and also remove the "index.php" remove the URL because Codeigniter tutorials only contain apache's rewriterule which isn't valid on nginx. 如何停止此操作并删除“index.php”删除URL,因为Codeigniter教程仅包含在nginx上无效的apache重写文件。

I believe that codeigniter uses the front-controller pattern, which will redirect all requests to index.php using a rewrite rule. 我相信codeigniter使用前端控制器模式,它将使用重写规则将所有请求重定向到index.php。

As the rewrite rules are for apache and not nginx, the server is actually looking for a directory called search which lives under another directory called index.php and so on. 由于重写规则适用于apache而不是nginx,服务器实际上正在寻找一个名为search的目录,该目录位于另一个名为index.php目录下,依此类推。

I don't have much experience when it comes to nginx, but I believe this blog post can help you come up with rewrite rules on nginx. 关于nginx,我没有太多经验,但我相信这篇博文可以帮助你提出关于nginx的重写规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM