[object Object]

← back to 1980swallpaper

add 301 redirect from old .html URLs to clean extensionless form

569c890a72cdddd8b455da6988dc0630a667c0ae · 2026-06-01 07:16:58 -0700 · SteveStudio2

Files touched

Diff

commit 569c890a72cdddd8b455da6988dc0630a667c0ae
Author: SteveStudio2 <steve@designerwallcoverings.com>
Date:   Mon Jun 1 07:16:58 2026 -0700

    add 301 redirect from old .html URLs to clean extensionless form
---
 server.js | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/server.js b/server.js
index 6f4971d..5bc497d 100644
--- a/server.js
+++ b/server.js
@@ -154,6 +154,13 @@ app.use((req, res, next) => {
   next();
 });
 
+// Clean URLs: redirect old /care.html -> /care (301), then serve extensionless.
+app.get(/^\/(.+)\.html$/i, (req, res) => {
+  const qi = req.originalUrl.indexOf('?');
+  const search = qi >= 0 ? req.originalUrl.slice(qi) : '';
+  if (req.path === '/index.html') return res.redirect(301, '/' + search);
+  return res.redirect(301, '/' + req.params[0] + search);
+});
 // Clean URLs: serve /care -> care.html etc.
 app.use(express.static(path.join(__dirname, 'public'), { extensions: ['html'] }));
 

← 24a538c harden site-nav window.open with noopener,noreferrer  ·  back to 1980swallpaper  ·  Remove Big Red widget — never UX-worked, collided with Help 6af3fa3 →