[object Object]

← back to Pastelwallpaper

301 redirect legacy /(care|history|sourcing|trade).html + /index.html to clean URLs before static

5ba231df4340822cb1fad1c96ef63fab53a7f150 · 2026-06-01 07:42:10 -0700 · Steve Abrams

Files touched

Diff

commit 5ba231df4340822cb1fad1c96ef63fab53a7f150
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon Jun 1 07:42:10 2026 -0700

    301 redirect legacy /(care|history|sourcing|trade).html + /index.html to clean URLs before static
---
 server.js | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/server.js b/server.js
index cf08f9d..987ddb5 100644
--- a/server.js
+++ b/server.js
@@ -164,6 +164,14 @@ app.use((req, res, next) => {
   }
   next();
 });
+// Canonical clean URLs: 301 the legacy *.html form -> extension-less path
+// (and /index.html -> /) BEFORE express.static, so the static dir doesn't
+// also serve the .html form as duplicate content. Nav links are already clean.
+app.get(/^\/(care|history|sourcing|trade)\.html$/i, (req, res) => {
+  res.redirect(301, '/' + req.params[0].toLowerCase());
+});
+app.get(/^\/index\.html$/i, (req, res) => res.redirect(301, '/'));
+
 app.use(express.static(path.join(__dirname, 'public')));
 
 // Clean-URL routes for extension-less nav links.

← f2d3e91 sister-site nav window.open gets noopener,noreferrer feature  ·  back to Pastelwallpaper  ·  Remove Big Red widget — never UX-worked, collided with Help 5623d66 →