Check 02.15 · Architecture and navigation

Avoid infinite URL spaces

Find the calendars, relative links, sessions and pagination that generate endless URLs, then close them off with 404s, fixed links or robots.txt.

Priority
Critical
Difficulty
Intermediate
Estimated time
2 h to 2 days
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

An infinite URL space is an area of the site where crawlers can keep generating new URLs without ever stopping: a calendar that always offers the next month, a relative link that stacks up /blog/blog/blog/, a session ID added to every link, pagination that returns a 200 all the way to ?page=999999. Every URL looks different, none brings new content. The check consists of detecting these traps and closing them: the server returns a 404 for anything that does not exist, links are built correctly, and the areas that generate URLs stay out of crawling.

Why it matters

Google's documentation on URL structure names the main causes of excess URLs: additive filtering, irrelevant parameters (referral, sorting, session IDs), calendars that generate links to past and future dates with no limit, and broken relative links that produce nested paths when the server does not return the right code for a page that does not exist.

A crawler that falls into such a space spends part of its visits there. On a small site, the effect is often invisible; on a site of several thousand pages, it delays the crawling of new content and loads the server. The generated URLs can also end up in the index as empty duplicates, or as “soft 404s”: pages that return a 200 even though they display nothing.

Generative engine crawlers also explore by following links, and their publishers document their safeguards poorly. A site without traps keeps them, like Googlebot, from going round in circles.

What it improves

  • Crawling Crawler visits go to useful pages. Strong effect on large sites, weak on a site of a few dozen pages.
  • Indexing Fewer empty duplicates and soft 404s in the reports.
  • Server load Fewer pages generated for nothing, especially costly calendar or search pages.
  • Report readability Crawl stats and logs reflect the real site.
  • Rankings No direct effect.

How to check

Can the server say “does not exist”? Three tests, each must return 404:

curl -s -o /dev/null -w "%{http_code}\n" "https://example.com/page-inexistante-$(date +%s)/"
curl -s -o /dev/null -w "%{http_code}\n" "https://example.com/blog/blog/blog/"
curl -s -o /dev/null -w "%{http_code}\n" "https://example.com/blog/?page=999999"

A 200 on any of them points to a potential infinite space. Add your own cases: a calendar month twenty years from now (/agenda/2046/01/), a product ID that does not exist.

What does a crawler find? Run Screaming Frog on the site, then:

  • URL tab, “Repetitive Path” (repeated segments) and “Multiple Slashes” filters;
  • URL tab, “Parameters” filter, sorted by number of URLs per pattern;
  • a crawl that never ends, or whose number of URLs far exceeds the number of known pages, gives away a trap. Limit the crawl in Configuration > Spider > Limits (depth, number of parameters) to identify it without overloading the machine.

What do crawlers do? In Search Console, the Crawl stats report shows volumes by response code and sample URLs. In the server logs, group the URLs requested by Googlebot by first path segment to see where the visits go:

grep -i "googlebot" /var/log/nginx/access.log | awk '{print $7}' | cut -d/ -f2 | cut -d'?' -f1 | sort | uniq -c | sort -rn | head

See also identify crawler traps (opens in a new tab) and analyze crawl stats (opens in a new tab).

How to implement

Before you start

Symptom Likely cause Fix
/blog/blog/blog/article/ Links relative to the current folder (href="blog/article") and a server that returns a 200 for everything Root-relative links (href="/blog/article/"), 404 for unknown paths
/agenda/2031/07/, /agenda/1987/02/ Unbounded calendar Links limited to a useful range, nofollow on links to generated future dates, 404 outside the range
?sid=…, ;jsessionid=… Session in the URL Cookie-based session
?page=4812 returning a 200, empty list Unbounded pagination 404 beyond the last page
?tri=prix&tri=prix&tri=prix Parameters appended to the current URL instead of replaced Links built from the base URL, constant order
/recherche/thé/vert/thé/… Internal search as a path, links to generated searches Search kept out of crawling, see handle internal search results (opens in a new tab)
?v=1716921600 different on every page Timestamp added to links Remove the parameter from HTML links

Principles, in order of preference:

  1. Do not generate the link: fixing it at the source is the only permanent fix.
  2. Return a 404 for everything that does not exist. Google recommends this code for non-existent pagination pages and empty combinations, and to Google a 404 is a strong signal not to come back.
  3. Block with robots.txt the URL-generating areas that must remain accessible to visitors (calendar, search, sorting). Google mentions this approach for dynamic search results, calendars and sorting or filtering features.

Warning: noindex does not close an infinite space. Google has to crawl each URL to read the tag: the visits continue.

For catalog filters, see control filters and facets (opens in a new tab); for session and tracking parameters, control URL parameters (opens in a new tab).

Apache

Versions Apache 2.4.

Return a 404 for paths in which one or more segments repeat in a row (/blog/blog/, /a/b/a/b/), in the .htaccess file before the CMS rules:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(.+/)\1
RewriteRule ^ - [R=404,L]

First check that no legitimate URL repeats a segment. For calendars, block the area in robots.txt and limit the links in the application (see the following sections). Test with sudo apachectl configtest, then reload.

Nginx

Versions Nginx 1.24 and later.

In the server block, the same rule for repeated segments:

location ~ "^/(.+/)\1" {
    return 404;
}

Also check the fallback to the application: try_files $uri $uri/ /index.php?$query_string; sends every unknown URL to the application, which must then return a 404 itself. An application that returns the homepage with a 200 for every unknown path is the most common cause of infinite spaces created by relative links. Reload with sudo nginx -t && sudo systemctl reload nginx.

WordPress

Versions WordPress 6.4 to 7.1; Yoast SEO 20.4 and later for crawl optimization.

  • Pagination: WordPress already returns a 404 beyond the last archive page.
  • Search: WordPress adds noindex to search results pages. To block them from being crawled, add Disallow: /?s= and Disallow: /search/ to robots.txt, then supplement with your SEO plugin if needed: Yoast SEO, in Settings > Advanced > Crawl optimization, filters spammy internal searches and can redirect /search/… URLs to the ?s= form.
  • Event calendars: limit navigation in the plugin's settings if it allows it, and block the generated views (by month, by day, iCal exports) in robots.txt after checking their URL form.
  • Relative links: a theme or page builder that writes href="contact/" instead of href="/contact/" creates nested paths. Fix the template or the menu (Appearance > Menus, URL field, on a classic theme; Appearance > Editor > Navigation on a block theme).
  • Virtual robots.txt: WordPress generates it on the fly; a physical file at the root replaces it.

Shopify

Versions Shopify online store, all plans, November 2026.

Shopify returns 404s for unknown paths and its default robots.txt already blocks search, the cart, and sorted and filtered collections. The risks mainly come from apps (booking calendars, third-party filters): test their URLs with curl and, if needed, add a rule in robots.txt.liquid.

Laravel

Versions Laravel 10 to 13.

Put bounds on every input that produces URLs:

Route::get('/agenda/{year}/{month}', [AgendaController::class, 'show'])
    ->whereNumber(['year', 'month'])
    ->name('agenda.show');
public function show(int $year, int $month): View
{
    abort_if($month < 1 || $month > 12, 404);

    $requested = CarbonImmutable::create($year, $month, 1);
    $first = CarbonImmutable::now()->startOfMonth()->subYear();
    $last = CarbonImmutable::now()->startOfMonth()->addYear();

    abort_if($requested->lt($first) || $requested->gt($last), 404);

    return view('agenda.show', [
        'events' => Event::forMonth($requested)->get(),
        'next' => $requested->addMonth()->lte($last) ? $requested->addMonth() : null,
    ]);
}

CarbonImmutable comes from Carbon\CarbonImmutable and forMonth is a scope on your model. The link to the next month is only displayed within the range; Google also recommends a rel="nofollow" on links to dynamically generated future dates. For pagination, abort_if($items->isEmpty() && $items->currentPage() > 1, 404). A Route::fallback() route must return a view with a 404 status, never the homepage.

Next.js

Versions Next.js 15 and 16 (App Router).

With the App Router, a dynamic route whose values are known in advance accepts only those values:

// app/agenda/[year]/[month]/page.tsx
export const dynamicParams = false;

export async function generateStaticParams() {
  return getMonthsInRange().map(({ year, month }) => ({ year: String(year), month: String(month) }));
}

Any other value returns a 404. For truly dynamic routes, call notFound() when the data does not exist or falls outside the range. getMonthsInRange is your function that lists the months to publish.

With Next.js 16's cacheComponents option, dynamicParams is no longer available: values missing from generateStaticParams are rendered on demand. notFound() is still required in the page, but a call that happens after the first part of the response has been sent keeps the 200 status (Next.js then adds noindex). To get a real 404, reject out-of-range values in proxy.ts, at the root:

// proxy.ts
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
import { isMonthInRange } from '@/lib/agenda';

export function proxy(request: NextRequest) {
  const [, , year, month] = request.nextUrl.pathname.split('/');

  if (!isMonthInRange(Number(year), Number(month))) {
    return new NextResponse('Page not found', { status: 404 });
  }

  return NextResponse.next();
}

export const config = {
  matcher: '/agenda/:year/:month',
};

isMonthInRange is your function that checks the range. Check the status with curl -I https://example.com/agenda/2031/07.

Shared hosting

The .htaccess block from the Apache section works with most hosts. Upload robots.txt to the site root. If the CMS returns the homepage with a 200 for every unknown URL, fix it in the CMS: no server rule will make up for it.

Common mistakes

  • Homepage or generic page returning a 200 for every unknown URL: this is the entry point of most infinite spaces.
  • Links relative to the current folder in a menu or template.
  • Relying on noindex: crawlers keep crawling.
  • Blocking with robots.txt URLs that should be fixed: the faulty link stays in the pages and visitors follow it.
  • A calendar open to the future with no bound and no nofollow.
  • Parameters stacked up on every click on a filter or sort option.
  • Redirecting non-existent URLs to the homepage instead of returning a 404: Google often treats them as soft 404s. See fix soft 404s (opens in a new tab).

Frequently asked questions

What is an infinite URL space?

An infinite URL space is a part of a site where a crawler can endlessly produce new URLs without finding any new content: a calendar that always offers the next month, relative links that stack up folders, session IDs, pagination that returns a 200 for any number. Crawlers waste crawl time there, at the expense of the site's useful pages.

How can I tell whether my site contains a crawler trap?

Test a few made-up URLs with curl: a page that does not exist, a repeated path such as /blog/blog/, a very high page number. Each one must return a 404. Then run a crawl with Screaming Frog and look at the repeated path and parameter filters. A crawl that never ends, or that finds far more URLs than real pages, points to a trap.

Should a calendar be blocked in robots.txt?

Block the automatically generated views, such as endless months or days, if they bring nothing in search. Keep the event pages themselves crawlable, since they have real content. Google also recommends adding nofollow to links pointing to dynamically generated future calendar pages. The best option remains limiting navigation in the application and returning a 404 outside the useful range.

Is noindex enough to neutralize an infinite space?

No. To read a noindex tag, Google has to crawl the page: an infinite space set to noindex therefore keeps consuming crawler visits. Noindex removes URLs from the index; it does not remove them from crawling. Fix the source of the links, return a 404 for URLs that should not exist, and block with robots.txt the URL-generating areas that must remain accessible to visitors.

Updated on

Topic checklist (PDF)

And now?

In the “Architecture and navigation” topic

  1. Organize pages by topic and hierarchy
  2. Create pillar pages and supporting content
  3. Limit the click depth of strategic pages (three clicks if possible)
  4. Detect orphan pages
  5. Optimize menus and submenus
  6. Implement breadcrumbs
  7. Optimize footer links
  8. Use crawlable HTML links
  9. Create short, stable and descriptive URLs
  10. Separate words with hyphens
  11. Standardize letter case and trailing slashes
  12. Control URL parameters
  13. Control pagination and infinite scroll
  14. Control filters and facets
  15. Avoid infinite URL spaces
  16. Avoid categories that add no value
  17. Check links to commercial pages