caddy/github-redirect/index.php

8 lines
326 B
PHP

<?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);
?>