Cgit和Nginx的URL重写

有线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; }

更新,解决

这是cgit虚拟根设置= /我也更新了我的Nginx.conf,现在url重写!

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; }

这与Nginx没有任何关系,代码生成的URL有一个错误

页面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 。

设置virtual-root=/ in / etc / cgitrc为我解决了这个问题。

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....