mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-06-20 15:42:41 +02:00
Stop hardcoding hostnames
- sets a hostname for Codeberg Pages as HOSTNAME_PAGES (can be overriden) - replaces this occurence in /var/www/pages
This commit is contained in:
parent
9b0953c7a7
commit
d668245696
2 changed files with 12 additions and 9 deletions
|
@ -6,6 +6,9 @@ function send_response($code, $message = "") {
|
|||
exit();
|
||||
}
|
||||
|
||||
$hostname_fqdn = "${HOSTNAME_FQDN}";
|
||||
$hostname_pages = "${HOSTNAME_PAGES}";
|
||||
|
||||
$domain_parts = explode('.', $_SERVER['HTTP_HOST']);
|
||||
$subdomain = implode(".", array_slice($domain_parts, 0, -2));
|
||||
$tld = end($domain_parts);
|
||||
|
@ -36,11 +39,11 @@ if ($tld === "org") {
|
|||
} else {
|
||||
$owner = strtolower(array_shift($request_url_parts));
|
||||
if (!$owner) {
|
||||
header("Location: https://codeberg.page");
|
||||
header("Location: https://" . $hostname_pages);
|
||||
exit;
|
||||
}
|
||||
if (strpos($owner, ".") === false) {
|
||||
$h = "Location: https://" . $owner . ".codeberg.page/" . implode("/", $request_url_parts);
|
||||
$h = "Location: https://" . $owner . "." . $hostname_pages . "/" . implode("/", $request_url_parts);
|
||||
if ($_SERVER['QUERY_STRING'] !== "")
|
||||
$h .= "?" . $_SERVER['QUERY_STRING'];
|
||||
header($h);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue