有线URL重写问题
当我去的时候
http://git.example.org/foo
效果很好,回复会出现。然而,该页面上的链接再次追加了/foo,即
http://git.example.org/foo/foo/commit
当我去URL的时候
http://git.example.org/foo/commit?id=123123
它可以工作,但是页面上的每个链接看起来都像
http://git.example.org/foo/commit/foo/snapshot/foo/4f0be51d35fe3160a9122894723b69df69a6fb7e.zip?id=4f0be51d35fe3160a9122894723b69df69a6fb7e
这是我的nginx.conf,我错过了什么吗?
server {
listen 80;
server_name git.example.org;
root /var/www/htdocs/cgit;
index cgit.cgi;
location ~* ^.+\.(css|png|ico)$ {
expires 30d;
}
if ($request_filename = cgit.cgi){
rewrite ^/([^/]+/.*)$ /cgit.cgi?url=$1 last;
}
location / {
try_files $uri @cgit;
}
location @cgit {
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME $document_root/cgit.cgi;
fastcgi_param HTTP_HOST $server_name;
fastcgi_param PATH_INFO $uri;
include fastcgi_params;
}
access_log /var/log/nginx/cgit_access.log;
error_log /var/log/nginx/cgit_error.log warn;
}更新,解决
这是虚拟-root=/的cgit设置,我也更新了我的nginx.conf,urls现在重写了!!
server {
listen 80;
server_name git.mengzhuo.org;
root /var/www/htdocs/cgit;
location ~* ^.+\.(css|png|ico)$ {
expires 30d;
}
location / {
index cgit.cgi;
fastcgi_param SCRIPT_FILENAME $document_root/cgit.cgi;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param HTTP_HOST $server_name;
fastcgi_param PATH_INFO $uri;
fastcgi_param QUERY_INFO $uri;
include "fastcgi_params";
}
access_log /var/log/nginx/cgit_access.log;
error_log /var/log/nginx/cgit_error.log warn;
}发布于 2013-04-25 14:59:15
这与Nginx无关,在生成URL的代码中有一个bug。
在http://git.example.org/foo页面上,有一个链接编写为:
<a href="foo/commit">Click to commit</a>对于服务器来说,它应该是绝对的,因为:
<a href="/foo/commit">Click to commit</a>或相对于当前目录,如:
<a href="commit">Click to commit</a>大概是在代码中的某个地方,您插入了cgit,您正在foo中填充,您应该在其中传递/foo。
发布于 2014-03-22 16:06:57
在/etc/cgitrc中设置virtual-root=/为我解决了这个问题。
https://stackoverflow.com/questions/16182421
复制相似问题