开发者

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).

Now, when I go to domain.com/dev, my codeigniter website works fine, but when I load an controller, e.g. domain.com/index.p开发者_StackOverflow中文版hp/search it gives me an 404 error.

In the error logs of domain.com it shows this:

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.


I believe that codeigniter uses the front-controller pattern, which will redirect all requests to index.php using a rewrite rule.

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.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜