【发布时间】:2014-01-03 19:46:35
【问题描述】:
我正在尝试在 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;
}
}
【问题讨论】:
-
您是否正确设置了 .htaccess 和 bootstrap.php(如果不确定,最好发布两者的相关部分)?
-
nginx 不像 apache 那样使用 .htaccess 规则。您在服务器配置中看到的内容等同于 htaccess 规则。是的,我已经更新了引导程序中的 base_url 以指向这个位置。