In short
When content is gone for good and no page really replaces it, its URL must respond with 404 Not Found or 410 Gone, along with a helpful error page. No 200 with a “not found” message, no redirect to an unrelated page. Once this is done, every removed URL returns 404 or 410, no longer appears in the sitemaps or the internal links, and gradually drops out of the indexes.
Why it matters
The HTTP status code is the only reliable signal a crawler receives about whether a page exists. Google documents the same handling for all 4xx codes (except 429): if the URL was indexed, it is removed from the index; if it is new, it is not processed. Its crawl budget guide adds that a 404 is a strong signal not to crawl the URL again, even though Google never forgets an address it knows: it simply comes back less and less often.
A 410 explicitly says “permanently removed”, a 404 says “not found”. Google's documentation makes no difference in how it handles the two. Choose 410 for a deliberate, lasting removal and 404 by default: both are correct.
What breaks when this is not done:
- Page returning
200with an error message: Google has to guess that it is an error. It classifies it as a soft 404, keeps crawling it and reports it in Search Console. See fix soft 404s (opens in a new tab). - Redirect to the homepage or to an unrelated page: Google states that it may be treated as a soft 404, and the visitor does not find what they were looking for. See avoid redirecting all removed pages to the homepage (opens in a new tab).
- Outdated content left online: an expired offer or incorrect information stays indexed. Generative engines that rely on a search index or read the page live can keep citing it.
Good to know: 404s do not penalize a site. Search Console Help states that a 404 response is not necessarily a problem if the page was removed without being replaced.
What it improves
- Indexing Removed URLs drop out of the index as they are recrawled, instead of lingering as soft 404s.
- Crawling Crawlers come back to these URLs less and less often and spend their visits on active pages. The effect is noticeable mainly on large sites.
- Generative engine answers Less risk of an assistant citing a page that no longer exists, provided the index it queries has been refreshed. There is no guaranteed timeframe.
- Visitor experience A clear error page with navigation and search rather than a confusing redirect.
- Reliable reports Genuine cases appear under “Not found (404)” in Search Console, separate from the errors you need to fix.
- Rankings No direct effect on the other pages.
How to check
Prepare a supprimees.txt file with the removed URLs (one per line), then test each one without following redirects:
while read -r url; do
curl -s -o /dev/null -w "%{http_code} %{redirect_url} $url\n" "$url"
done < supprimees.txt
Compliant result: 404 or 410, with no redirect URL. A 200, or a 301 to the homepage or to /404, needs fixing.
Then:
- Search Console: in the Page indexing report, open “Not found (404)” and check that the examples are indeed content removed on purpose, then review “Soft 404”.
- Sitemaps: no removed URL should appear in them.
curl -s https://example.com/sitemap.xml | grep -c "ancienne-collection"should return0. - Internal links: a crawl with Screaming Frog lists the internal links that still point to 404s or 410s (
Response Codestab,Client Error (4xx)filter, then theInlinkstab in the lower pane). - Bing: URL Inspection in Bing Webmaster Tools gives the status of a specific URL.
How to implement
Before you start
Decide URL by URL:
| Situation | Response |
|---|---|
| Content removed, nothing equivalent on the site | 410 if the removal is deliberate and permanent, otherwise 404 |
| Content moved, merged or replaced by a page that meets the same need | 301 to that page (permanent moves (opens in a new tab)) |
| Product temporarily out of stock | Keep the page at 200 (temporary stockouts (opens in a new tab)) |
| Product permanently discontinued with a successor | 301 to the successor (discontinued products (opens in a new tab)) |
| Content to remove urgently (personal data, serious error) | 404 or 410, plus a temporary removal request |
Then, for each removed URL:
- Remove it from the sitemaps and feeds. See exclude redirects, errors and noindex pages from sitemaps (opens in a new tab).
- Remove or replace the internal links pointing to it: menus, articles, related product blocks. See fix broken internal links (opens in a new tab).
- Do not block it in robots.txt: Google must be able to crawl it to see the 404 or the 410.
- Serve a helpful error page with the right code: a message, search, links to the main sections. See create a helpful 404 page (opens in a new tab).
- In an emergency, also submit a request in Search Console's Removals tool. It hides the URL for about six months; only the 404 or the 410 makes the removal permanent. Bing Webmaster Tools offers an equivalent URL blocking tool, whose name and location vary between versions.
Apache
Versions Apache 2.4.
In the virtual host or the .htaccess file, before the CMS rewrite rules:
ErrorDocument 404 /404.html
ErrorDocument 410 /410.html
# Permanent removals, URL by URL
Redirect gone /ancienne-collection-2019/
Redirect gone /blog/offre-black-friday-2022/
# Removal of a family of URLs
RedirectMatch gone ^/evenements/salon-20(1[0-9]|2[0-3])/
The ErrorDocument path must stay local: with a full URL, Apache sends a redirect instead of the error code. For thousands of URLs, an external table is easier to read. RewriteMap only works in the server or virtual host configuration:
RewriteEngine On
RewriteMap supprimees "txt:/etc/apache2/supprimees.txt"
RewriteCond ${supprimees:%{REQUEST_URI}|0} =1
RewriteRule ^ - [G]
The /etc/apache2/supprimees.txt file contains one line per URL: /ancienne-collection-2019/ 1. The [G] flag returns 410. Reload with sudo apachectl configtest && sudo systemctl reload apache2.
Nginx
Versions Nginx 1.18 and later.
In the http context, for example /etc/nginx/conf.d/supprimees.conf:
map $uri $contenu_supprime {
default 0;
include /etc/nginx/supprimees.map;
}
The /etc/nginx/supprimees.map file contains one line per URL, ending with a semicolon: /ancienne-collection-2019/ 1;. A line such as ~^/evenements/salon-20(1[0-9]|2[0-3])/ 1; covers a family of URLs with a regular expression.
In the server block:
error_page 404 /404.html;
error_page 410 /410.html;
location = /404.html {
internal;
}
location = /410.html {
internal;
}
if ($contenu_supprime) {
return 410;
}
If Nginx reports a hash table size error on reload, add map_hash_bucket_size 128; in the http context. Reload with sudo nginx -t && sudo systemctl reload nginx.
Cloudflare
Versions Cloudflare dashboard, WAF custom rules on Pro plans and above, Workers on all plans, November 2026.
Cloudflare's redirect rules only produce 3xx codes. There are two options for a 410 at the edge:
- WAF custom rule (Pro plans and above): in
Security > Security rules, create a custom rule with the expression below and theBlockaction, then a custom HTML response with the410code (the allowed range is 400 to 499).
(http.request.uri.path in {"/ancienne-collection-2019/" "/blog/offre-black-friday-2022/"})
- Worker: a script that returns
new Response(html, { status: 410 })for a list of URLs, available on all plans.
The simplest option is still to let the origin return the code. By default, Cloudflare caches 404 and 410 responses for the files it caches, for three minutes when the origin sends no Cache-Control header. After a removal, purge the affected URLs in Caching > Configuration.
AWS
Versions AWS console (S3, CloudFront, Application Load Balancer), November 2026.
S3: deleting the object is enough, but S3 returns 403 Access Denied instead of 404 when whoever queries the bucket lacks the s3:ListBucket permission. Behind CloudFront with origin access control (OAC), grant CloudFront s3:ListBucket on the bucket ARN in the bucket policy, otherwise removed content shows up as 403. See fix unjustified 403s (opens in a new tab).
CloudFront: in the distribution's Error pages tab, a custom error response can serve /404.html for the 404 error; keep the 404 response code. After a removal, create an invalidation for the affected URLs.
Application Load Balancer: listener rules accept a fixed response action with a 4xx code, which is useful for a short list of paths; beyond that, handle it in the application.
Plesk
Versions Plesk Obsidian 18.0.
On a site running Apache behind Nginx, the .htaccess block from the Apache section works. In Nginx-only mode, paste the following into Websites & Domains > your domain > Apache & nginx Settings > Additional nginx directives:
location = /ancienne-collection-2019/ {
return 410;
}
location ~ ^/evenements/salon-20(1[0-9]|2[0-3])/ {
return 410;
}
cPanel
Versions cPanel & WHM 110 and later, Jupiter theme.
The Domains > Redirects screen only offers 301 and 302 redirects: it is no use here. Paste the Redirect gone lines from the Apache section into public_html/.htaccess with the File Manager. The Advanced > Error Pages screen lets you customize the 404 page served.
Shared hosting
At OVHcloud, o2switch, Infomaniak, Ionos or Hostinger, the .htaccess file at the site root accepts ErrorDocument, Redirect gone and RedirectMatch gone. Then check with curl that the code returned is indeed 410. If your host offers an option to “redirect errors to the homepage”, turn it off.
WordPress
Versions WordPress 6.4 to 7.1; Rank Math 1.0.x, Redirection 5.x, Yoast SEO Premium 20 and later plugins.
A deleted post or page (with the trash emptied) returns a 404. For a 410:
- Rank Math:
Rank Math > Redirections > Add New, paste the source URLs, skip the destination and choose the “410 Content Deleted” maintenance code. - Redirection: create a rule with the “Error (404)” action, then choose the 410 HTTP code in its settings. A regular expression rule covers a family of URLs.
- Yoast SEO Premium: the redirect manager also offers the 410 type.
Check the result with curl after clearing the page cache: several users report 410s served as 404s because of a cache. Also remember attachment pages and tags that have become empty.
Shopify
Versions Shopify admin, all plans, November 2026.
A deleted product, collection or page returns a 404, served with the theme's 404 template. Shopify does not let you return a 410; the 404 is enough. When a product has a genuine successor, create a URL redirect instead from Content > Menus, in the URL redirects list. Customize templates/404.json to suggest collections and search.
PrestaShop
Versions PrestaShop 1.7, 8 and 9.
On the page of a deactivated product, the SEO tab sets the offline behavior: choose the no-redirection option (404 or 410) when no product replaces it, and otherwise the permanent redirect (301) to an equivalent product or category. The 410 options have existed since PrestaShop 8; in 1.7, only the 404 option is available. The Classic and Hummingbird themes provide a templates/errors/410.tpl template to customize.
Laravel
Versions Laravel 10 to 13.
For a list of removed paths, add a route at the end of routes/web.php:
Route::get('{path}', fn () => abort(410))
->whereIn('path', config('content.gone_paths'))
->name('contentGone');
With config/content.php:
<?php
return [
'gone_paths' => [
'ancienne-collection-2019',
'blog/offre-black-friday-2022',
],
];
For a soft-deleted model, return 410 from the controller: abort_if($post->trashed(), 410); (with withTrashed() binding on the route). Customize the page in resources/views/errors/410.blade.php; without that file, Laravel displays its generic error page with the right code.
Next.js
Versions Next.js 15 and 16.
For missing content, call notFound() before any streaming: the page returns 404. For a 410, intercept the paths before rendering; only the file and function names change between versions.
Next.js 16
Create proxy.ts at the project root (or in src/):
import { NextResponse, type NextRequest } from 'next/server';
const cheminsSupprimes = new Set([
'/ancienne-collection-2019',
'/blog/offre-black-friday-2022',
]);
export function proxy(request: NextRequest) {
if (!cheminsSupprimes.has(request.nextUrl.pathname)) {
return NextResponse.next();
}
return new NextResponse(
'<!doctype html><html lang="en"><title>Content removed</title><p>This content has been removed. <a href="/">Back to the homepage</a></p></html>',
{ status: 410, headers: { 'Content-Type': 'text/html; charset=utf-8' } },
);
}
export const config = {
matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
};
Next.js 15 and earlier
Create middleware.ts at the project root (or in src/):
import { NextResponse, type NextRequest } from 'next/server';
const cheminsSupprimes = new Set([
'/ancienne-collection-2019',
'/blog/offre-black-friday-2022',
]);
export function middleware(request: NextRequest) {
if (!cheminsSupprimes.has(request.nextUrl.pathname)) {
return NextResponse.next();
}
return new NextResponse(
'<!doctype html><html lang="en"><title>Content removed</title><p>This content has been removed. <a href="/">Back to the homepage</a></p></html>',
{ status: 410, headers: { 'Content-Type': 'text/html; charset=utf-8' } },
);
}
export const config = {
matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
};
Common mistakes
- Returning
200with “Page not found”: that is a soft 404. The code must be 404 or 410. - Redirecting to
/404: the error page then responds at another URL, after a 301 or a 302. - Blocking removed URLs in robots.txt: Google can no longer see the 404 and keeps the URL known for longer.
- Forgetting the sitemaps and internal links: crawlers and visitors keep landing on errors.
- Serving a 404 for content that has a replacement: a 301 passes on the signals and serves the visitor better.
- Relying on the Removals tool alone: the temporary removal expires after about six months if the page still returns 200.
- Letting a cache serve the old page: purge the CDN and the page cache after every removal.
Frequently asked questions
Should I return 404 or 410 for a removed page?
Both are fine for removed content with no equivalent. Google's documentation handles 404 and 410 codes the same way: the URL drops out of the index as it is recrawled. A 410 expresses a deliberate, permanent removal, a 404 an absence. Choose 410 when you deliberately remove content, and 404 by default. If an equivalent page exists, prefer a 301 redirect to it.
How long does it take for a 404 page to disappear from Google?
Google gives no fixed timeframe for removing a URL that returns 404 or 410. It drops out of the index after Googlebot has crawled it again and seen the error, which depends on how often the site and the page are crawled. For an urgent removal, also submit a request in Search Console's Removals tool, which hides the URL for about six months while the 404 takes effect.
Do 404 errors hurt the site's SEO?
No, 404 errors on genuinely removed content do not penalize the site. Search Console Help states that a 404 response is not necessarily a problem if the page was removed without a replacement. The problem lies with unintended 404s: broken internal links, active pages deleted by mistake, URLs still listed in the sitemaps. Those are what you need to fix, not the code itself.
Should I block removed pages in robots.txt?
No. A URL blocked in robots.txt can no longer be crawled, so Google does not see the 404 or 410 code and may keep the address known for longer, sometimes displayed without a description. Leave removed URLs crawlable, remove them from the sitemaps and internal links, and let the error code do its job.
Resources
- Google: How HTTP status codes affect Google's crawlersdevelopers.google.com
- Google Search Central: Large site owner's guide to managing your crawl budgetdevelopers.google.com
- Search Console Help: Page indexing reportsupport.google.com
- Search Console Help: Removals toolsupport.google.com
- MDN: 410 Gonedeveloper.mozilla.org
- Apache: Redirect directive and Nginx: map modulehttpd.apache.org
- Cloudflare: custom responses for WAF rulesdevelopers.cloudflare.com
Updated on
Topic checklist (PDF)