如何在Nginx的子目录中托管Kohana安装?

时间:2014-01-03 19:46:36

标签: nginx rewrite kohana

我正在尝试在Nginx上托管Kohana安装。不同之处在于我试图从子目录而不是Web根本身提供它。

问题: 在尝试访问网址http://myproject.tld/Project/Welcome时,系统会收到错误消息:No input file specified.

经过调查,我注意到这实际上被重写为http://myproject.tld/index.php/Project/Welcome/,应该是http://myproject.tld/Project/index.php/Welcome/

如图所示:

2014/01/02 23:10:57 [debug] 20952#0: *30 http copy filter: 0 "index.php/Project/Welcome?"
2014/01/02 23:10:57 [debug] 20952#0: *30 http finalize request: 0, "index.php/Project/Welcome?" a:1, c:1

现在,我完全理解为什么会这样。因为我从一个子目录托管,该子目录将存在于request_uri中并附加到url重写。如果我从文档根目录服务,这将不是问题。我希望有人可以指出我正确的方向来解决这个特殊的打嗝。

设置信息

的nginx / 1.4.4

Kohana 3.3.1

服务器配置

server {
    listen   80;
    server_name mydomain.tld;

    access_log /home/<user>/logs/mydomain-access.log;
    error_log /home/<user>/logs/mydomain-error.log debug;

    # main root
    root   /home/<user>/domains/mydomain.tld;
    index index.php index.html;

    location / {
        expires off;
        try_files $uri $uri/;
    }

    # Prevent access to hidden files
    location ~ /\. {
        deny all;
    }

    location /Project/ {
        rewrite ^(.+)$ index.php$request_uri last;
    }

    location ~* \.php {
        fastcgi_pass 127.0.0.1:9000;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param KOHANA_ENV development;
        fastcgi_cache off;
        fastcgi_index index.php;
    }
}

1 个答案:

答案 0 :(得分:0)

要获得http://myproject.tld/Project/index.php/Welcome/重写,您应该在/ base_url块中的/application/bootstrap.php - /Project/中将Kohana配置为Kohana::init()