Translate some urls in redirect from Gitea to GitHub

This commit is contained in:
BBaoVanC 2022-06-20 19:48:33 -05:00
parent 2ac6af6b5c
commit a26b936989
2 changed files with 10 additions and 1 deletions

View File

@ -16,7 +16,9 @@ git.bbaovanc.com {
@404 status 404 @404 status 404
handle_response @404 { handle_response @404 {
handle /bbaovanc/* { handle /bbaovanc/* {
redir https://github.com{uri} permanent root * /etc/caddy/github-redirect/
rewrite * /index.php?uri={uri}
php_fastcgi unix//run/php/php-fpm.sock
} }
handle { handle {

View File

@ -0,0 +1,7 @@
<?php
$uri = $_GET["uri"];
$uri = preg_replace('/(\/bbaovanc\/.*?(?=\/))\/src\/(commit|branch)/', '$1/blob', $uri);
$uri = preg_replace('/(\/bbaovanc\/.*?(?=\/))\/(commits|blame)\/(branch|commit)/', '$1/$2', $uri);
header('Status: 301 Moved Permanently');
header('Location: https://github.com' . $uri);
?>