mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-01-19 00:57:53 +00: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,12 +6,12 @@
|
|||
<meta name="keywords" content="Codeberg, Website, Pages, Free, Hosting, Git, Repository">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="icon" href="https://design.codeberg.org/logo-kit/favicon.ico" type="image/x-icon" />
|
||||
<link rel="icon" href="https://design.codeberg.org/logo-kit/favicon.svg" type="image/svg+xml" />
|
||||
<link rel="apple-touch-icon" href="https://design.codeberg.org/logo-kit/apple-touch-icon.png" />
|
||||
<link rel="icon" href="https://design.${HOSTNAME_FQDN}/logo-kit/favicon.ico" type="image/x-icon" />
|
||||
<link rel="icon" href="https://design.${HOSTNAME_FQDN}/logo-kit/favicon.svg" type="image/svg+xml" />
|
||||
<link rel="apple-touch-icon" href="https://design.${HOSTNAME_FQDN}/logo-kit/apple-touch-icon.png" />
|
||||
|
||||
<!-- Details and License: https://fonts.codeberg.org/fonts/inter/ -->
|
||||
<link rel="stylesheet" type="text/css" href="https://fonts.codeberg.org/dist/inter/Inter%20Web/inter.css">
|
||||
<!-- Details and License: https://fonts.${HOSTNAME_FQDN}/fonts/inter/ -->
|
||||
<link rel="stylesheet" type="text/css" href="https://fonts.${HOSTNAME_FQDN}/dist/inter/Inter%20Web/inter.css">
|
||||
|
||||
<!-- License: http://www.apache.org/licenses/LICENSE-2.0.txt -->
|
||||
<!-- Material Design icons by Google -->
|
||||
|
@ -111,12 +111,12 @@
|
|||
<body>
|
||||
<center>
|
||||
<div class="container">
|
||||
<a href="https://codeberg.org"><img class="logo" src="https://design.codeberg.org/logo-kit/icon.svg" alt="Go to codeberg.org"></a><br>
|
||||
<a href="https://${HOSTNAME_FQDN}"><img class="logo" src="https://design.${HOSTNAME_FQDN}/logo-kit/icon.svg" alt="Go to ${HOSTNAME_FQDN}"></a><br>
|
||||
|
||||
<div class="header">
|
||||
<div class="name">Codeberg Pages.</div>
|
||||
<div class="description">Static pages for your projects.</div>
|
||||
<code style="margin-top: 15px;">https://<your_username>.codeberg.page/</code>
|
||||
<code style="margin-top: 15px;">https://<your_username>.${HOSTNAME_PAGES}/</code>
|
||||
</div>
|
||||
|
||||
<div class="elevated">
|
||||
|
|
|
@ -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…
Reference in a new issue