Skip to content
How-to guide

How to Capture Hallucinated URLs With 301 Redirects

The short answer

To fix 404 errors from ChatGPT links, find the missing URLs that AI visitors hit, map each one to the closest real page by meaning, and add a 301 redirect for it. Where no close page exists, keep the 404 and make that page useful. Ahrefs says this is worth doing if the effort is low, not a major growth lever 1.

  • An Ahrefs study found AI assistants send people to likely-404 pages 2.87 times as often as Google Search does 1.
  • The rate is small: 0.43% across assistants against 0.15% for Google, so do not expect a big traffic win 1.
  • Redirect only when a genuinely close page exists. A wrong redirect is worse than an honest 404.
  • A missing page must still return a 404 status. A 200 with an error message is a soft 404 4.

Why do AI tools send people to pages that do not exist?

Because a model predicts what a plausible URL would look like, and sometimes it guesses wrong. Ahrefs published a study on 2 September 2025 covering about 16 million URLs. In one test of URLs people actually clicked, ChatGPT led to a likely 404 page 1.01% of the time. The average across six assistants was 0.43%, against 0.15% for Google, which is 2.87 times as often 1.

Handle these numbers with care. Ahrefs flagged a page as a likely 404 if its title contained '404' or 'not found', calls this 'not a perfect test', and drew on sites using Ahrefs Web Analytics 1. A second test of cited URLs gave different rates, 2.38% for ChatGPT and 0.84% for Google's top 20 results, because the base is different 1. Separate Vercel data shows what bots request: 34.82% of ChatGPT crawler fetches hit 404 pages, against 8.22% for Googlebot 2. That is crawler behaviour, not what users see.

Do it step by step

0 of 8 done0%

  1. In GA4, filter landing pages for the AI Assistant channel and not-found page titles. Then run the log command on your server logs. Merge both lists into one sheet.

    Tip: Lower-case and strip query strings so duplicates group together.

  2. Sort by AI-referred visits over the last 90 days. Work the top 20 first. The rest can wait for the pattern check.

  3. For each URL, write the intent in a few words. Many invented URLs read like page titles.

  4. Pick the closest real page by meaning. If none is close, mark it keep 404. Record the decision in the mapping sheet.

    Tip: Ask whether you would be comfortable if a customer saw the destination.

  5. Use the template for your server. Prefer exact rules. Use a pattern rule only if the old and new paths follow the same structure.

    Tip: Keep the rules in version control so you can review and undo them.

  6. Run the test loop against the mapping file. Confirm each URL returns a 301 or 308 to the final page in one hop, and that unmapped URLs still return a real 404.

  7. Add links to your top ten pages, a search box and a contact link. Confirm that it returns a 404 status code.

  8. Re-pull the data monthly for three months, then quarterly. Add new rules and retire any that no longer match traffic.

Your ticks are saved in this browser only.

Copy-ready templates

Find AI-referred 404s in your server log

bash
# Count 404s whose referrer is an AI assistant (Apache/nginx "combined" log format)
awk '$9 == 404 && $11 ~ /chatgpt\.com|perplexity\.ai|gemini\.google\.com|copilot\.microsoft\.com|claude\.ai/ {print $7}' access.log \
  | sort | uniq -c | sort -rn | head -50

Works on the common Apache and nginx combined log format, where field 7 is the path, 9 the status and 11 the referrer. Adjust the field numbers if your format differs.

Mapping sheet (CSV)

text
old_path,ai_source,visits_90d,intent,new_target,decision
/pricing-plans,chatgpt.com,14,See prices,/pricing,301
/blog/how-to-choose-payroll,perplexity.ai,6,Choose a provider,/guides/choose-a-payroll-provider,301
/services/payroll-audit-cost,chatgpt.com,3,Cost of an audit,,Keep 404 and improve the 404 page
/case-studies/acme,gemini.google.com,2,Unknown,,Check if a page ever existed

Placeholder rows. The visit counts are invented examples. The decision column should be 301 or keep 404.

nginx redirects

text
# Inside your server { } block. One exact-match location per invented URL.
location = /pricing-plans { return 301 /pricing; }
location = /blog/how-to-choose-payroll { return 301 /guides/choose-a-payroll-provider; }

# A pattern rule, used only when the old path maps cleanly to the new one:
rewrite ^/resources/(.*)$ /guides/$1 permanent;

Reload nginx after editing. Test before and after. Paths are examples.

Apache redirects

text
# .htaccess or virtual host (mod_alias)
Redirect permanent "/pricing-plans" "https://www.example.com/pricing"
Redirect permanent "/blog/how-to-choose-payroll" "https://www.example.com/guides/choose-a-payroll-provider"

# Pattern rule, only when the old path maps cleanly to the new one:
RedirectMatch permanent "^/resources/(.*)$" "https://www.example.com/guides/$1"

Needs mod_alias, which is enabled on most hosts. Paths are examples.

Next.js redirects

text
// next.config.js
module.exports = {
  async redirects() {
    return [
      { source: '/pricing-plans', destination: '/pricing', permanent: true },
      {
        source: '/blog/how-to-choose-payroll',
        destination: '/guides/choose-a-payroll-provider',
        permanent: true,
      },
    ]
  },
}

permanent: true returns a 308, which Google treats as permanent. Paths are examples.

Test every rule from the mapping file

bash
# map.csv holds lines like: /pricing-plans,https://www.example.com/pricing
while IFS=, read -r old new; do
  result=$(curl -s -o /dev/null -w '%{http_code} %{redirect_url}' "https://www.example.com$old")
  echo "$old => $result (expected 301 or 308 $new)"
done < map.csv

Replace the domain. A healthy row shows 301 or 308 and the expected target. To check for chains, run curl -sIL on one URL and count the Location lines.

Is it worth fixing on your site?

Usually it is a small job with a small payoff. The Ahrefs author says it is probably worthwhile when the fix takes very little effort, and is not a huge growth lever 1. A visitor who clicked an AI answer wanted something specific, so a correct redirect rescues a visitor who already wanted something specific, but the numbers are small.

Use a simple rule. If your AI-referred 404s are a handful a month, redirect the top few and move on. If they run into the hundreds, look for a pattern: the AI may be inventing a URL style that you could support with one rule.

What to do depending on what you find
What you findAction
A few 404s, each with an obvious matching pageAdd exact 301 redirects.
Many 404s sharing a pattern, such as /resources/ instead of /guides/Add one pattern rule, then test.
A 404 for a page that never existed and has no close matchKeep the 404. Improve the 404 page.
A 404 for a page you deletedRedirect to the replacement if one exists. If not, a 404 or 410 is fine.
Repeated requests for something you should offerConsider creating that page.

What do you need, and how long does it take?

You need access to either your analytics (GA4 or similar), your server logs, or both, plus the ability to add redirect rules. The first pass takes about two hours; that is our estimate. After that, a 20-minute check each month is enough.

The free AI 404 Redirect Builder matches broken URLs to your real pages and writes the rules.

How do you find the broken URLs?

Use two sources and combine them. In GA4, Google's default AI Assistant channel groups visits from sources such as ChatGPT, Gemini, DeepSeek, Copilot and Grok, and it excludes Google's AI Overviews and AI Mode, which count as Organic Search 8. Open a landing-page report for that channel and look for pages with titles like 'Page not found'.

Your server log is more complete. Filter for 404 responses where the referrer is an AI assistant, using the command in the templates. Treat counts as a floor, because some AI apps and browsers do not pass a referrer, and those visits can show up as direct traffic. Check your own logs to see how much this affects you. See how to track AI traffic in GA4 for the setup.

How do you choose the right destination for each URL?

Read the invented URL as a question. What did the visitor want? Send them to the page that answers that question best. If two real pages could fit, choose the one that gives the answer first. If none fits, do not force a redirect.

Never send every broken URL to the home page. That fits poorly with what the visitor asked, and it hides real gaps from you. This is our advice rather than a rule Google states.

Mapping invented URLs to real pages (illustrative)
  • /pricing-plans -> /pricing: same intent, one obvious match, so 301.
  • /blog/how-to-choose-payroll -> /guides/choose-a-payroll-provider: the page moved from blog to guides, so 301.
  • /services/payroll-audit-cost -> no page exists: keep the 404 and list your service pages on the 404 page.
  • /case-studies/acme -> check the archive: if a page ever existed, redirect to its replacement. If not, leave it.

Which kind of redirect should you use?

Use a permanent redirect. Google says permanent redirects tell it to show the new target in results, and it treats 301 and 308 as permanent 3. Temporary ones such as 302 keep the old URL in search results, which is not what you want here 3. Next.js sends a 308 when you set permanent to true, and it uses 307 for temporary redirects 5.

Point each rule straight at the final page, not at another redirect. Test with a command-line request after you deploy. The templates show nginx, Apache and Next.js versions. Nginx documents return 301 and rewrite with the permanent flag 6, and Apache's Redirect directive accepts the permanent keyword 7.

What should your 404 page do for the rest?

Ahrefs suggests a second option: improve your 404 page with a list of useful resources for disappointed AI visitors, rather than writing many redirects 1. Put your top pages, a search box and your contact link on it.

Make sure it really returns a 404 status. Google says a page that shows an error with a 200 status is flagged as a soft 404 in Search Console, and it treats 4xx errors, including 410, the same way 4. Redirecting a deleted page to a close replacement is also consistent with Bing's advice to retire redundant pages with a 301 redirect 9.

How do you check it worked, and keep watching?

Run the test loop in the templates against your mapping file. Every row should return a 301 or 308 to the expected page, with no second hop. Then check your analytics a month later: AI-referred sessions that previously landed on a not-found page should now reach the right page.

Repeat monthly for the first quarter, then quarterly. If the same invented patterns keep appearing, add a pattern rule or consider whether you should publish that page.

When is this not worth doing?

Skip it if you see no AI-referred 404s in your data, if the missing pages are junk with no real intent, or if you have no analytics or logs to measure with yet. In that case, start with how to check whether AI bots can crawl your site and read what hallucinated URLs are.

Frequently asked questions

Are hallucinated URLs a big problem?

They are real but small. Ahrefs found an average 0.43% likely-404 rate across AI assistants against 0.15% for Google in its click-based test 1. ChatGPT was highest at 1.01%. For most sites that means a handful of visitors a month, so fix the obvious ones and do not over-invest.

Should I redirect every broken AI link to my home page?

No. Redirect only to a page that answers what the visitor wanted. A blanket redirect sends people to something unrelated and hides the real gaps. If there is no close page, keep the 404 and make that page useful, as Ahrefs suggests 1. This is our advice, not a Google rule.

Is a 301 or a 302 better for this?

Use a permanent redirect. Google says permanent redirects tell it to show the new target in results, while temporary redirects keep the source page in results 3. A 301 or 308 fits a URL that should always lead to the new page.

Can I stop AI tools from inventing URLs?

We found no way to control it. The links come from the model, not from your site. What you can control is your own URL structure: clear, predictable paths are easier to guess correctly, and your 404 page and redirects limit the damage when a guess is wrong.

About the author

Rahil Jain

Rahil Jain is an AI SEO (answer engine and generative engine optimisation) consultant and co-founder of Chalk Labs.

LinkedIn · Method and credentials

Sources

  1. New Study: How Often Do AI Assistants Hallucinate Links? (16 Million URLs Studied) · AhrefsOpened October 20, 2026. Supports: Published 2 September 2025. Test 1: average 0.43% likely-404 rate across six assistants vs 0.15% for Google (2.87x), ChatGPT 1.01%; Test 2: ChatGPT 2.38% vs 0.84% for Google top 20; method caveats; advice to 301 redirect or improve the 404 page; not a huge growth lever.
  2. The rise of the AI crawler · VercelOpened October 20, 2026. Supports: 34.82% of ChatGPT crawler fetches and 34.16% of Claude crawler fetches hit 404 pages, vs 8.22% for Googlebot; bot-side fetch data, December 2024.
  3. Redirects and Google Search · Google Search CentralOpened October 20, 2026. Supports: Permanent redirects show the new target in results; temporary redirects keep the source; 301 and 308 treated as permanent. Page last updated 2026-04-14.
  4. HTTP status codes, and network and DNS errors · Google Search CentralOpened October 20, 2026. Supports: 404 means content does not exist; 2xx error pages flagged as soft 404; 4xx errors except 429 treated alike. Page last updated 2026-02-04.
  5. redirects (next.config.js) · Next.js documentationOpened October 20, 2026. Supports: permanent: true uses status 308 and false uses 307; source, destination and permanent properties; read from the Next.js docs bundled with the installed version.
  6. Module ngx_http_rewrite_module · nginx.orgOpened October 20, 2026. Supports: return code URL syntax for 301; rewrite regex replacement with the permanent flag returns 301.
  7. Apache Module mod_alias · Apache HTTP Server ProjectOpened October 20, 2026. Supports: Redirect directive with the permanent status keyword returns 301; RedirectMatch uses regular expressions.
  8. Default channel group definitions · Google Analytics HelpOpened October 20, 2026. Supports: AI Assistant channel covers sources such as ChatGPT, Gemini, DeepSeek, Copilot and Grok and excludes Google's AI Overviews and AI Mode, which are Organic Search.
  9. Does Duplicate Content Hurt SEO and AI Search Visibility? · Microsoft Bing Webmaster BlogOpened October 20, 2026. Supports: Advice to consolidate or 301 redirect older or redundant pages. Post dated 19 December 2025.
How this page was made. Built on Rahil Jain's AI SEO method and drafted with AI research assistance. Every statistic links to the page we read it on (opened October 20, 2026 or nearby). Published October 20, 2026; last updated October 20, 2026. Chalk Labs sells AI SEO services, so we have a commercial interest in this topic. Spotted an error? Tell us and we will fix it.