← back to Silkwallcoverings
301-redirect legacy .html pages to clean URLs (kill duplicate-content from static dir)
a11fb5a75c7b3d6b05358f1ca528a4e03c1c8d55 · 2026-06-01 07:47:40 -0700 · Steve Abrams
Files touched
Diff
commit a11fb5a75c7b3d6b05358f1ca528a4e03c1c8d55
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Mon Jun 1 07:47:40 2026 -0700
301-redirect legacy .html pages to clean URLs (kill duplicate-content from static dir)
---
server.js | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/server.js b/server.js
index 8b04814..9b3cfa7 100644
--- a/server.js
+++ b/server.js
@@ -157,6 +157,13 @@ app.use((req, res, next) => {
if (/\.bak([.-]|$)|\.pre-|\.orig$/i.test(req.path)) return res.status(404).end();
next();
});
+// 301 the legacy *.html form -> clean URL (the static dir still holds the .html
+// files; without this they'd serve at BOTH forms = duplicate content). Must run
+// before express.static. /index.html -> /, everything else -> extension-less.
+app.get(/^\/(care|history|sourcing|trade|vocabulary|index)\.html$/i, (req, res) => {
+ const page = req.params[0].toLowerCase();
+ res.redirect(301, page === 'index' ? '/' : '/' + page);
+});
app.use(express.static(path.join(__dirname, 'public')));
app.get('/api/products', (req, res) => {
← 02575fa fix: remove leaked bak file from public/ and patch 404-guard
·
back to Silkwallcoverings
·
Remove Big Red widget — never UX-worked, collided with Help d8a3db8 →