Adjust the URL of a repository page?


#1

My apologies if this is an elementary question or if I missed something in the docs, but is there any straightforward way to alias the URL of a repository page or redirect another URL to it? I have a small gitea site, with only one or two repositories and few users, and I would rather publish URLs like http://gitea.mytld/proj/ rather than http://gitea.mytld/myuser/proj – is there any quick way to alias the former to the latter? Ideally, then, gitea.mytld/proj/wiki would also get you to the wiki for “proj” as well, etc. Thanks for any help you can offer.


#2

In particular, it appears to me that the format of (at least most) URLs is set in the code in the file gitea/routers/routes/routes.go, and that the blocks in there which open with clauses like m.Group("/:username/:reponame", func() { are responsible for serving up the pages like gitea.mytld/myuser/proj (possibly with additional suffixes). So I can refine my question: (a) Is it the case that the only way to change to which URLs gitea responds is to change this routes.go file and recompile gitea? and (b) If so, then, well, I have no experience with Go. I don’t suppose anyone can quickly suggest additional code for routes.go which would take a URL of the form gitea.mytld/proj/possibly-more-stuff and if proj is the name of a unique repository among all users on the site, belonging to auser, treat that URL as if it had been gitea.mytld/auser/proj ? Again, thanks for any thoughts/help.


#3

I think this is a feature request, maybe you could go to https://github.com/go-gitea/gitea/issues to create one issue?


#4

Actually, since I am using Apache reverse proxy anyway to direct traffic to the Gitea server, I was able to do what I wanted in the VirtualHost entry as follows: I changed

<VirtualHost *:80>
  ServerName gitea.mytld
  ProxyPass / http://localhost:3000/
  ProxyPassReverse / http://localhost:3000/
</VirtualHost>

to

<VirtualHost *:80>
  ServerName gitea.mytld
  ProxyPass /proj http://localhost:3000/auser/proj
  ProxyPassReverse /proj http://localhost:3000/auser/proj
  ProxyPass / http://localhost:3000/
  ProxyPassReverse / http://localhost:3000/
</VirtualHost>

(The difference is just the addition of the new second and third lines inside the VirtualHost clause.) Yes, this needs to be done for each project that one wants to redirect this way, but it suffices for my case of just a handful of projects. So I decided not to add to the reams of issues on the github repository for gitea. But maybe this workaround will help if there’s anyone else out there that wants to provide shorter URLs for specific projects. Thanks for your feedback, @lunny.