【问题标题】:Lighttpd rewrite for Codeigniter breaking on certain URLsLighttpd 重写 Codeigniter 在某些 URL 上的中断
【发布时间】:2012-03-05 06:20:49
【问题描述】:

我从 apache 迁移到 lighttpd,从那时起,某些 URL 会中断重写并给出 404。access.log 和 error.log 中没有关于实际 URL 被击中的详细信息。

这些工作: http://192.168.1.250/loop/rest/admin

但不是这些: http://192.168.1.250/loop/rest/admin/logs/file::log-2012-02-14.php

如果我跳过重写并使用 http://192.168.1.250/loop/rest/index.php?/admin/logs/file::log-2012-02-14.php

我得到了我想要的,

这是我的重写规则:

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

任何帮助将不胜感激。

【问题讨论】:

    标签: codeigniter mod-rewrite lighttpd codeigniter-2


    【解决方案1】:

    我在 lighttpd 上测试我的 codeigniter 应用程序时遇到了同样的问题

    这对我有用:

      url.rewrite = (
          ".*\.(js|ico|gif|jpg|png|swf|css|html)$" => "$0",
          "^/(.*)$" => "index.php/$1"
     )
    

    也许你可以试试这个设置:

     url.rewrite = (
              ".*\.(js|ico|gif|jpg|png|swf|css|html)$" => "$0",
              "^/(.*)$" => "/loop/rest/index.php/$1"
         )
    

    确保您在顶部有未注释的 mod_rewrite .. 它默认带有 # 在它前面。

    【讨论】:

    • 感谢您的意见,但是我发现了一个更简单的规则:)
    【解决方案2】:

    我找到了正确的规则:

    首先请确保您的根指令指向您的 CI 设置的根目录。

    root /var/www/loop;
    

    那么这个位置指令就可以正常工作了:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-08
      • 1970-01-01
      相关资源
      最近更新 更多