I am attempting to host a Kohana installation on Nginx. The difference is that I am trying to serve it up from a subdirectory as opposed to the web root itself.
我试图在Nginx上主持Kohana安装。不同之处在于我试图从子目录而不是Web根本身提供它。
The problem: When trying to access the url, http://myproject.tld/Project/Welcome
, I am given the error message: No input file specified.
问题:当试图访问URL,http://myproject.tld/Project/Welcome时,我收到错误消息:没有指定输入文件。
Upon investigation, I noticed that this is in fact being rewritten as http://myproject.tld/index.php/Project/Welcome/
when it should be http://myproject.tld/Project/index.php/Welcome/
在调查之后,我注意到这实际上被重写为http://myproject.tld/index.php/Project/Welcome/,它应该是http://myproject.tld/Project/index.php/Welcome/
as seen here:
如下所示:
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
Now, I understand fully why it is happening. Because I am hosting from a subdirectory that will exist within the request_uri and is appended to the url rewrite. If I were serving from the document root this wouldn't be an issue. What I'm hoping is someone can point me in the correct direction for solving this particular hiccup.
现在,我完全理解为什么会这样。因为我从一个子目录托管,该子目录将存在于request_uri中并附加到url重写。如果我从文档根目录服务,这将不是问题。我希望有人可以指出我正确的方向来解决这个特殊的打嗝。
Setup Information:
设置信息:
nginx/1.4.4
nginx的/ 1.4.4
Kohana 3.3.1
Kohana 3.3.1
Server configuration:
服务器配置:
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 个解决方案
#1
0
To get http://myproject.tld/Project/index.php/Welcome/
rewriting you should configure Kohana in /application/bootstrap.php - base_url
to /Project/
in Kohana::init()
block.
要获得http://myproject.tld/Project/index.php/Welcome/重写,您应该在/application/bootstrap.php - base_url中将Kohana配置为Kohana :: init()块中的/ Project /。
#1
0
To get http://myproject.tld/Project/index.php/Welcome/
rewriting you should configure Kohana in /application/bootstrap.php - base_url
to /Project/
in Kohana::init()
block.
要获得http://myproject.tld/Project/index.php/Welcome/重写,您应该在/application/bootstrap.php - base_url中将Kohana配置为Kohana :: init()块中的/ Project /。