[object Object]

← back to Saloonwallpaper

clean-URL: 301 redirect legacy /(care|history|sourcing|trade).html + /index.html -> clean URLs (mounted before express.static; was serving both forms = duplicate content)

0f72e6dc639a9c58af29a4e76f8c30cedb6e4b81 · 2026-06-01 07:48:30 -0700 · Steve

Files touched

Diff

commit 0f72e6dc639a9c58af29a4e76f8c30cedb6e4b81
Author: Steve <steve@designerwallcoverings.com>
Date:   Mon Jun 1 07:48:30 2026 -0700

    clean-URL: 301 redirect legacy /(care|history|sourcing|trade).html + /index.html -> clean URLs (mounted before express.static; was serving both forms = duplicate content)
---
 server.js | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/server.js b/server.js
index 5ca45a8..0e81f94 100644
--- a/server.js
+++ b/server.js
@@ -164,6 +164,11 @@ for (const [route, file] of Object.entries(CLEAN_URLS)) {
   app.get(route, (req, res) => res.sendFile(path.join(__dirname, 'public', file)));
 }
 
+// Canonicalize: 301 the legacy .html form (+ /index.html) to its clean URL so
+// the static .html files don't serve duplicate content alongside CLEAN_URLS.
+app.get(/^\/(care|history|sourcing|trade)\.html$/i, (req, res) => res.redirect(301, '/' + req.params[0].toLowerCase()));
+app.get('/index.html', (req, res) => res.redirect(301, '/'));
+
 app.use(express.static(path.join(__dirname, 'public')));
 
 // Shared filter — apply q/aesthetic/vendor, optionally skipping one dimension

← 19b87d4 facets: drill-down counts via shared filterProducts() — each  ·  back to Saloonwallpaper  ·  Remove Big Red widget — never UX-worked, collided with Help 2335b90 →