LogoLogo

Managing Duplicate Content When Using next.config.js Rewrites

Published

Rewrites: The Powerful Tool That Could Accidentally Kill Your SEO

I’ve seen many Next.js developers discover the rewrites feature in next.config.js and go crazy with it. "It’s amazing! I can show the same page on ten different URLs!" No, don't do that. That is the definition of **Duplicate Content**, and it’s an SEO suicide mission. Google hates seeing the same content on multiple URLs because it doesn't know which one to rank. In 2026, using rewrites requires a disciplined "Canonical First" mindset. I call this "Path Hygiene," and it’s the only way to use rewrites safely.

The "Internal Shadow" Problem

A rewrite is different from a redirect. A redirect tells the user (and bot) to go to a new URL. A rewrite silently serves content from one path while the URL in the bar stays the same. I remember an audit where a client used rewrites to map /category/shoes to /landing/special-offer. Both URLs were live and both were being indexed! This caused "Keyword Cannibalization," where the two pages competed against each other. I call this "The Ghost Page Effect"—you've created a duplicate without even realizing it.

Technical Real-Talk: Always use the canonical tag. If you are rewriting /path-b to show content from /path-a, the canonical tag on the page must ALWAYS point to /path-a. In Next.js, I handle this globally in my Metadata API. It’s your insurance policy against duplicate content penalties.

Safe Rewrites for SaaS and Multi-Tenancy

Rewrites are essential for SaaS apps where you might want user.com/dashboard to show content from an internal route. But for SEO, you need to be careful. As I discussed in my guide on Middleware Redirects, you should use Middleware for logic and next.config.js for static rules. I remember a project where we used rewrites to handle a multi-lingual setup. We had to be extremely careful with our Hreflang Tags to ensure Google understood that these weren't duplicates, but localized variations. It’s a fine line between "Clever Routing" and "SEO Disaster."

Rewrites SEO Checklist

Action The Risk The SEO Fix
Dynamic Mapping Indexing "Shadow" paths Strict noindex on internal routes
Legacy URLs Split authority Use 301 Redirects, not Rewrites
Search Params Infinite duplicates Canonicalize to the "Clean" URL
A/B Testing Cloaking penalty Follow my A/B Testing guide

Combining clean rewrites with SGE-friendly metadata ensures that your "Shadow" paths never confuse the crawler. I’ve used this "Clean Path" strategy to help a large marketplace manage thousands of dynamic vanity URLs without a single duplicate content warning in Search Console. It’s about being in control of your site's structure.

Conclusion: Respect the URL

In 2026, the URL is a sacred part of your SEO. Don't multiply your paths without a clear plan. Use rewrites for power, but use canonicals for safety. Master the nuances of next.config.js, audit your indexed URLs regularly, and always keep your path structure lean. I’ve learned that the most successful Next.js sites are the ones that have a "One Page, One URL" philosophy. Be precise, be canonical, and rank high. Don't let your routing be your ruin.

Managing Duplicate Content When Using next.config.js Rewrites