mirror of
https://github.com/samber/awesome-prometheus-alerts.git
synced 2026-06-21 00:47:18 +08:00
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:
parent
6d8b2b3671
commit
e0311c3c09
6 changed files with 69 additions and 11 deletions
|
|
@ -64,20 +64,10 @@ function buildRedirects(base) {
|
||||||
|
|
||||||
const base = '/awesome-prometheus-alerts';
|
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({
|
export default defineConfig({
|
||||||
site: 'https://samber.github.io',
|
site: 'https://samber.github.io',
|
||||||
base,
|
base,
|
||||||
redirects: { ...buildRedirects(base), ...legacyHtmlRedirects },
|
redirects: buildRedirects(base),
|
||||||
output: 'static',
|
output: 'static',
|
||||||
integrations: [
|
integrations: [
|
||||||
sitemap({
|
sitemap({
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
User-agent: *
|
User-agent: *
|
||||||
Allow: /
|
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
|
# AI search bots — explicitly allowed for citation
|
||||||
User-agent: GPTBot
|
User-agent: GPTBot
|
||||||
|
|
|
||||||
16
site/src/pages/alertmanager.html.astro
Normal file
16
site/src/pages/alertmanager.html.astro
Normal 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>
|
||||||
16
site/src/pages/blackbox-exporter.html.astro
Normal file
16
site/src/pages/blackbox-exporter.html.astro
Normal 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>
|
||||||
16
site/src/pages/rules.html.astro
Normal file
16
site/src/pages/rules.html.astro
Normal 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>
|
||||||
16
site/src/pages/sleep-peacefully.html.astro
Normal file
16
site/src/pages/sleep-peacefully.html.astro
Normal 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>
|
||||||
Loading…
Reference in a new issue