I run a small launch directory. Last week I went through an SEO audit of it, expecting advice about content. Most of what it found were small technical bugs I had shipped myself. None of them were hard to fix, but every one of them was quietly costing crawl budget or clicks.
Here they are, with the fix for each.
1. /blog/ returned 404, /blog worked
My router matched exact paths. Anyone (or any site) linking with a trailing slash got a "not found" page.
Fix: one permanent redirect before routing.
if ( path . length > 1 && path . endsWith ( '/' ) && ! path . startsWith ( '/api/' ) ) { const clean = '/' + path . replace ( /^ \ /+| \ /+ $ / g , '' ) ; res . writeHead ( 301 , { Location : clean + search } ) ; return res . end ( ) ; }
Enter fullscreen mode
Exit fullscreen mode
Watch the '/' + ...replace(/^\/+/...) part. My first version kept leading slashes, so //evil.com/ would have redirected to //evil.com , which browsers read as another site.…