简体   繁体   中英

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, eg domain.com/index.php/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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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