Search code examples
codeignitermod-rewritelighttpdcodeigniter-2

Lighttpd rewrite for Codeigniter breaking on certain URLs


I moved from apache to lighttpd, and since then certain URLs break the rewriting and give 404. No details in access.log, error.log regarding what actual URL was hit.

These kind work: http://192.168.1.250/loop/rest/admin

But not these: http://192.168.1.250/loop/rest/admin/logs/file::log-2012-02-14.php

If I skip rewriting and use http://192.168.1.250/loop/rest/index.php?/admin/logs/file::log-2012-02-14.php

I get what I want,

Here is my rewrite rule:

url.rewrite-once = (
 "/(.*)\.(.*)" => "$0",
 "/(css|files|img|js|stats)/" => "$0",
 "^/([^.]+)$" => "/loop/rest/index.php/$1"
)

Any help would be appreciated.


Solution

  • I have found the correct rules:

    First of all please make sure that your root directive points to the root of your CI setupd.

    root /var/www/loop;
    

    Then this location directive will work perfectly fine:

    location /
      {
        if (!-e $request_filename)
        {
          rewrite ^/(.*)$ /index.php?/$1 last;
          break;
        }
      }