如何从Nginx上的子目录托管Kohana安装?

如何从Nginx上的子目录托管Kohana安装?,nginx,rewrite,kohana,Nginx,Rewrite,Kohana,我正在尝试在Nginx上托管Kohana安装。区别在于,我试图从一个子目录而不是web根目录本身提供它 问题: 尝试访问url时,http://myproject.tld/Project/Welcome,我收到错误消息:未指定输入文件。 经过调查,我注意到这实际上被改写为http://myproject.tld/index.php/Project/Welcome/应在何时使用http://myproject.tld/Project/index.php/Welcome/ 如图所示: 2014/01

我正在尝试在Nginx上托管Kohana安装。区别在于,我试图从一个子目录而不是web根目录本身提供它

问题: 尝试访问url时,
http://myproject.tld/Project/Welcome
,我收到错误消息:
未指定输入文件。

经过调查,我注意到这实际上被改写为
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
现在,我完全明白为什么会发生这种情况。因为我是从一个子目录托管的,该子目录将存在于请求uri中,并附加到url重写中。如果我是从文档根目录提供服务,这不会是一个问题。我希望有人能给我指出解决这个问题的正确方向

设置信息

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;
    }
}
nginx/1.4.4

科哈纳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;
    }
}
服务器{
听80;
服务器名称mydomain.tld;
access_log/home//logs/mydomain-access.log;
错误\u log/home//logs/mydomain-error.log调试;
#主根
root/home//domains/mydomain.tld;
index.php index.html;
地点/{
过期;
试试_文件$uri$uri/;
}
#阻止访问隐藏文件
位置~/\{
否认一切;
}
地点/项目/{
重写^(+)$index.php$request\u uri last;
}
位置~*\.php{
fastcgi_pass 127.0.0.1:9000;
包括fastcgi_参数;
fastcgi\参数脚本\文件名$document\根$fastcgi\脚本\名称;
fastcgi_param KOHANA_环境开发公司;
快速CGI_缓存关闭;
fastcgi_index.php;
}
}

获取
http://myproject.tld/Project/index.php/Welcome/
rewriting您应该在/application/bootstrap.php-
base\u url
中将Kohana配置为
Kohana::init()
块中的
/Project/

您是否正确设置了.htaccess和bootstrap.php(如果不确定,最好发布两者的相关部分)?nginx不像apache那样使用.htaccess规则。您在服务器配置中看到的与htaccess规则等效。是的,我已经在引导程序中更新了base_url以指向这个位置。