fix: replace Astro redirects with static meta-refresh pages for legacy .html URLs

GitHub Pages is a static host and does not support server-side redirects.
Astro redirects config only works for SSR targets, so legacyHtmlRedirects had
no effect. Replace with real .html.astro pages using meta http-equiv=refresh
and link rel=canonical. Also disallow legacy URLs in robots.txt.
This commit is contained in:
Samuel Berthe 2026-04-21 16:39:01 +02:00
parent 6d8b2b3671
commit e0311c3c09
No known key found for this signature in database
GPG key ID: 64863511FFBD0E3C
6 changed files with 69 additions and 11 deletions

View file

@ -64,20 +64,10 @@ function buildRedirects(base) {
const base = '/awesome-prometheus-alerts';
/** Legacy .html page redirects from the pre-Astro (Jekyll) site.
* These pages 404 after the Astro migration since they moved to trailing-slash directories.
* rules.html alone had 105 referring domains and was the #1 traffic page critical to preserve. */
const legacyHtmlRedirects = {
[`${base}/rules.html`]: { destination: `${base}/rules/`, status: 301 },
[`${base}/alertmanager.html`]: { destination: `${base}/alertmanager/`, status: 301 },
[`${base}/blackbox-exporter.html`]: { destination: `${base}/blackbox-exporter/`, status: 301 },
[`${base}/sleep-peacefully.html`]: { destination: `${base}/sleep-peacefully/`, status: 301 },
};
export default defineConfig({
site: 'https://samber.github.io',
base,
redirects: { ...buildRedirects(base), ...legacyHtmlRedirects },
redirects: buildRedirects(base),
output: 'static',
integrations: [
sitemap({

View file

@ -1,5 +1,9 @@
User-agent: *
Allow: /
Disallow: /awesome-prometheus-alerts/rules.html
Disallow: /awesome-prometheus-alerts/alertmanager.html
Disallow: /awesome-prometheus-alerts/blackbox-exporter.html
Disallow: /awesome-prometheus-alerts/sleep-peacefully.html
# AI search bots — explicitly allowed for citation
User-agent: GPTBot

View file

@ -0,0 +1,16 @@
---
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
const destination = `${base}/alertmanager/`;
---
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Redirecting…</title>
<link rel="canonical" href={destination} />
<meta http-equiv="refresh" content={`0; url=${destination}`} />
</head>
<body>
<p>Redirecting to <a href={destination}>{destination}</a>…</p>
</body>
</html>

View file

@ -0,0 +1,16 @@
---
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
const destination = `${base}/blackbox-exporter/`;
---
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Redirecting…</title>
<link rel="canonical" href={destination} />
<meta http-equiv="refresh" content={`0; url=${destination}`} />
</head>
<body>
<p>Redirecting to <a href={destination}>{destination}</a>…</p>
</body>
</html>

View file

@ -0,0 +1,16 @@
---
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
const destination = `${base}/rules/`;
---
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Redirecting…</title>
<link rel="canonical" href={destination} />
<meta http-equiv="refresh" content={`0; url=${destination}`} />
</head>
<body>
<p>Redirecting to <a href={destination}>{destination}</a>…</p>
</body>
</html>

View file

@ -0,0 +1,16 @@
---
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
const destination = `${base}/sleep-peacefully/`;
---
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Redirecting…</title>
<link rel="canonical" href={destination} />
<meta http-equiv="refresh" content={`0; url=${destination}`} />
</head>
<body>
<p>Redirecting to <a href={destination}>{destination}</a>…</p>
</body>
</html>