slugme.ioclean-url-slug-generator

URL Normalization for SEO: One Page, One URL

One page can live at dozens of URLs: uppercase, trailing slashes, www, tracking parameters. How URL normalization works and how to enforce it.

By 6 min read
URL Normalization for SEO: One Page, One URL

Here is a question worth asking about any page on your site: how many URLs does it actually answer to?

Take a single article. Without normalization, it might load at all of these:

http://example.com/blog/my-post
https://example.com/blog/my-post
https://www.example.com/blog/my-post
https://example.com/blog/my-post/
https://example.com/Blog/My-Post
https://example.com//blog/my-post
https://example.com/blog/my-post/index.html
https://example.com/blog/my-post?utm_source=newsletter
https://example.com/blog/my-post?ref=twitter&utm_source=x

To you, that's one page. To a search engine, it's nine URLs that happen to return the same content. Google will usually work out which one is the "real" one — its systems are good at clustering duplicates — but every variant costs crawl activity, can split links between addresses, and lets Google choose a canonical you didn't intend.

URL normalization is the practice of making sure each page has exactly one URL, and every other variant points to it.

What the standard says: RFC 3986 normalization

The URL specification, RFC 3986, defines normalizations that never change what a URL points to. Any software may apply them safely:

Normalization Before After
Lowercase scheme and host HTTPS://Example.COM/ https://example.com/
Uppercase percent-encoding hex /caf%c3%a9 /caf%C3%A9
Decode unreserved characters /%7Euser /~user
Remove dot-segments /a/./b/../c /a/c
Remove default port https://example.com:443/ https://example.com/
Empty path becomes / https://example.com https://example.com/

Browsers do most of this automatically. Note what is not on the list: lowercasing the path. Per the standard, /Page and /page are different resources, because servers are allowed to treat them differently.

What SEO adds: policy normalizations

Everything beyond RFC 3986 is a choice you make about your own site — "we use lowercase paths," "we don't use trailing slashes" — and then enforce. These are the decisions that matter:

1. One protocol: HTTPS

Redirect every http:// request to https://, permanently. HTTPS is a confirmed (light) ranking signal, and browsers label HTTP pages "Not secure". Add an HSTS header so browsers stop trying HTTP at all.

2. One hostname: www or not

Pick example.com or www.example.com and redirect the other. Neither ranks better. What matters is that both hostnames resolve — a missing DNS record for www means anyone who types it gets an error instead of a redirect — and that only one serves content.

3. One case: lowercase

Because paths are case-sensitive, /Blog/My-Post and /blog/my-post can both be indexed. Generate lowercase slugs, and redirect uppercase requests to lowercase. (Details in why URLs should be lowercase.)

4. One trailing-slash style

/blog and /blog/ are different URLs. Choose one — most frameworks have a default — and redirect the other. See trailing slashes in URLs.

5. No duplicate slashes or index files

//blog//post and /blog/post/index.html are classic accidental duplicates from template bugs and old static-site habits. Collapse repeated slashes and redirect index.html/index.php to the directory URL.

6. Parameters: canonicalize, don't multiply

Query parameters are where duplicates explode — tracking codes, sort orders, session IDs, and the same parameters in a different order (?a=1&b=2 vs ?b=2&a=1). Handle them by type:

  • Tracking parameters (utm_*, gclid, fbclid): leave them working for analytics, and rely on a self-referencing canonical tag on every page.
  • Session IDs in URLs: eliminate them; store sessions in cookies.
  • Sort/filter parameters: canonicalize to the unfiltered page unless the filtered view targets real search demand. See dynamic vs static URLs.

Google's guide to consolidating duplicate URLs lists the signals it uses to pick a canonical. In order of strength:

  1. Redirects (301/308) — a strong signal that the target is canonical. Use them for every variant that has no reason to exist.
  2. rel="canonical" — a strong hint for variants that must remain accessible. Put a self-referencing canonical on every page, using the absolute, normalized URL.
  3. Sitemap inclusion — a weaker signal. List only canonical URLs.
  4. Internal links — link to the canonical form everywhere. A site that redirects /blog/ to /blog but links to /blog/ in its menu is sending mixed signals.

These signals should all agree. Most normalization problems come from one of them contradicting the others — a canonical pointing to http://, a sitemap listing www, a nav linking with a trailing slash.

How to enforce it: a real example

Here is how we normalize URLs on Slugme.io itself, which runs on Next.js. Some rules come free from the platform, some are configuration, and one needs code.

Free: Next.js strips trailing slashes with a permanent redirect (/blog/ → /blog), and the host redirects http:// to https://.

Configuration — permanent redirects for legacy and guessable paths in next.config.ts. When the site moved from Nuxt to Next.js, it dropped its /fr, /es and /ar locale prefixes, so those now redirect to the matching language pages instead of returning 404s:

async redirects() {
  return [
    { source: '/fr', destination: '/french-slug-generator', permanent: true },
    { source: '/:locale(fr|es|ar|de)/:path+', destination: '/:path+', permanent: true },
    { source: '/privacy-policy', destination: '/privacy', permanent: true },
  ]
}

Code — lowercase and duplicate-slash normalization, in a small proxy.ts (Next.js 16's name for middleware):

import { NextResponse, type NextRequest } from 'next/server'

export function proxy(request: NextRequest) {
  const { pathname } = request.nextUrl

  const normalized = pathname
    .replace(/\/{2,}/g, '/')
    // Lowercase ASCII letters, but leave percent-escapes (%D8%A3…) alone
    // so encoded Arabic paths don't bounce through a pointless redirect.
    .replace(/%[0-9A-Fa-f]{2}|[A-Z]+/g, m => (m.startsWith('%') ? m : m.toLowerCase()))

  if (normalized === pathname) return NextResponse.next()

  const url = request.nextUrl.clone()
  url.pathname = normalized
  return NextResponse.redirect(url, 308)
}

export const config = {
  // Skip Next.js internals and files with extensions
  matcher: ['/((?!_next/|.*\\..*).*)'],
}

The percent-escape detail is easy to miss. Non-ASCII paths arrive percent-encoded with uppercase hex (%D8%A3). A naive pathname.toLowerCase() would change that to %d8%a3, trigger a redirect, and — while technically equivalent — waste a round trip on every Arabic or Cyrillic URL.

The same rules on other stacks

  • Nginx: return 301 https://example.com$request_uri; in the server blocks for http and the non-canonical host; merge_slashes on; (the default) only affects location matching, so add a rewrite if you want // paths to redirect; lowercase needs the Perl/Lua module or app-level logic.
  • Apache: RewriteCond %{HTTPS} off and host conditions for protocol/host; RewriteMap lc int:tolower (server config only) for lowercase.
  • Cloudflare: "Always Use HTTPS", a redirect rule for the hostname, and a Worker or dynamic redirect with lower() for case.
  • WordPress: enforces the site URL's protocol and host and its own trailing-slash style automatically; check that your SEO plugin outputs self-referencing canonicals.

How to audit your normalization

Test each variant of one important URL with curl and confirm it returns a single 301/308 hop to the canonical URL, which returns 200:

for u in http://example.com/blog/post https://www.example.com/blog/post \
         https://example.com/Blog/Post https://example.com/blog/post/ \
         https://example.com//blog/post; do
  printf '%s → ' "$u"; curl -s -o /dev/null -w '%{http_code} %{redirect_url}\n' "$u"
done

When we first ran this against Slugme.io, it surfaced two real problems: /Blog returned a 404 instead of redirecting, and the www hostname had no DNS record at all. The first is what the proxy above fixes; the second is a one-line DNS change rather than code. Neither showed up in normal browsing — which is exactly why this check is worth five minutes.

Then, in Google Search Console, open Page indexing and look at "Duplicate without user-selected canonical" and "Alternate page with proper canonical tag". The first is a list of normalization gaps; the second is normalization working as intended.

For individual URLs, the URL slug checker flags uppercase letters, spaces, parameters and other variants worth normalizing.

Checklist

  • HTTP → HTTPS, permanently, with HSTS
  • Both hostnames resolve; one redirects to the other
  • Uppercase paths redirect to lowercase
  • One trailing-slash style, the other redirects
  • Duplicate slashes and index.html redirect
  • Self-referencing absolute canonical on every page
  • Sitemap lists canonical URLs only
  • Internal links use the canonical form
  • Old URLs from migrations redirect in one hop

Frequently asked questions

What is the difference between URL normalization and canonicalization?

Normalization is the process of transforming URL variants into one standard form. Canonicalization is how search engines pick which URL represents a set of duplicates. You normalize — with redirects, canonical tags and consistent links — so that Google's canonicalization picks the URL you want.

Is rel=canonical enough, or do I need redirects?

Use redirects whenever the variant has no reason to exist (http, www, uppercase, trailing slash). Google treats rel=canonical as a strong hint, not a directive, and it can choose a different canonical. Keep canonical tags for variants that must stay accessible, like tracking or sort parameters.

Does Google treat URLs as case-sensitive?

Yes, for the path and query. The scheme and hostname are case-insensitive. /Page and /page are separate URLs to Google, which is why lowercase normalization matters.

Should I strip utm_ parameters with a redirect?

Usually not — redirecting would break analytics attribution. Leave them accessible and make sure every page outputs a self-referencing canonical tag pointing to the clean URL.

Keep reading