[object Object]

← back to Ffepurchasing

clean-URL: 301 redirect legacy /*.html -> extension-less routes (/index.html -> /, /trade-account.html -> /trade-account)

fc990f8bf42ef1706118e623a9a64c4af621d5c7 · 2026-06-01 07:28:18 -0700 · Steve Abrams

Files touched

Diff

commit fc990f8bf42ef1706118e623a9a64c4af621d5c7
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon Jun 1 07:28:18 2026 -0700

    clean-URL: 301 redirect legacy /*.html -> extension-less routes (/index.html -> /, /trade-account.html -> /trade-account)
---
 server.js | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/server.js b/server.js
index cf4aad0..ba1e699 100644
--- a/server.js
+++ b/server.js
@@ -108,6 +108,13 @@ app.use((req, res, next) => {
   next();
 });
 
+// Clean-URL canonicalization: 301 the legacy *.html forms to their extension-less
+// routes (runs before express.static so the .html never serves a duplicate URL).
+app.get(/^\/(.+)\.html$/i, (req, res) => {
+  const slug = req.params[0];
+  res.redirect(301, slug === 'index' ? '/' : '/' + slug);
+});
+
 app.use(express.static(path.join(__dirname, 'public')));
 
 // Shared filter — applied identically by /api/products and /api/facets so facet

← 1dadf89 noopener,noreferrer on sister-site constellation window.open  ·  back to Ffepurchasing  ·  Unique hero image (backsync from prod, fleet hero dedup 2026 1934fb3 →