Indexing and technical SEO guide
Remove a WordPress Page With the Right 404, 410, or Redirect
Redirect a retired page with a 301 when a real replacement exists; otherwise let it return 404 or 410. Then clear it from the sitemap and your internal links.
On this page
If another page answers the same need as the one you are retiring, send the old URL there with a 301 redirect. If nothing does, let the old URL return a 404 or a 410; Google treats the two the same way. Either way, finish the job by removing the URL from your sitemap and your internal links, and check the response with curl before you consider it done.
This guide assumes the decision to retire the page is already made. It covers carrying out that decision cleanly. A page that shows “not found” content while returning 200 is a different problem, covered in Fix soft 404 pages.
Choose the response
| Situation | Response | Why |
|---|---|---|
| A page with the same purpose exists, such as an updated version or the page you merged into | 301 to that page | Google’s HTTP status documentation says Google treats a 301 as “a strong signal” for the target |
| The page is gone and nothing replaces it | 404 or 410 | The same documentation says “all 4xx errors, except 429, are treated the same”: Google is told the content does not exist |
| The page is coming back, such as a seasonal offer | Keep it published, or use a 302 for a short absence | Google’s redirect guidance says temporary redirects show the source page in results |
| The page must be withdrawn for legal reasons | 451 if your tools support it | A separate status that RFC 7725 defines for access denied “as a consequence of a legal demand”; WP Visibility’s Redirects module offers it |
Both Google pages and the RFC were checked September 27, 2026.
Pick a destination a visitor would accept as an answer to what they came for. Sending every retired URL to the homepage or a loosely related category does not tell a visitor or Google where the content went. Google’s crawling troubleshooting page, checked September 27, 2026, gives the plain rule: if the page no longer exists, return 404 or 410; if it moved, return a 301.
A 404 for a removed page is not a fault to be cleaned up. For “Not found (404),” Google’s Page Indexing report help, checked September 27, 2026, says 404 responses “are not necessarily a problem, if the page has been removed without any replacement,” and advises a 301 only “if your page has moved.” A deleted page with no replacement that returns 404 is expected in that report.
What WordPress does when you delete a page
When you move a post or page to the trash, it stops being public and its address stops resolving to it. Two WordPress behaviors can then change what visitors actually get:
- Permalink guessing. WordPress may redirect a URL that would 404 to a published post with a similar slug. The
redirect_guess_404_permalink()reference, checked September 27, 2026, says it “attempts to guess the correct URL for a 404 request based on query vars,” and has been filterable since WordPress 5.5 withdo_redirect_guess_404_permalink(turn it off) andstrict_redirect_guess_404_permalink(exact slug matches only). A deleted/pruning-shears/can end up redirecting to/pruning-shears-review/, which may or may not be what you want. - Child pages and attachments.
wp_trash_post()changes the status of the page itself and trashes its comments, so child pages stay published and media uploaded to the page stays in the library. The children’s URLs still change:get_page_uri()builds a child’s path from its parent’s slug, and moving a page to the trash runswp_add_trashed_suffix_to_post_name_for_post(), which adds__trashedto its slug. All three references were checked September 27, 2026.
Check the old address after trashing it. Do not assume it returns a 404.
Implement the redirect or the missing-page response
Choose one layer to own the rule. Rules in two layers for the same URL are how chains and loops start.
In WordPress with WP Visibility. Turn on the Redirects module and add a rule with the old path as Source, the replacement as Target, and Status 301. For a page with no replacement, the same screen accepts 410, which answers the old address with a 410 and no target. If you changed a published page’s slug rather than deleting it, the module creates the 301 for you. Redirect a Changed URL covers the fields, the per-post Redirect (301) to field, and CSV import.
In Apache. The Redirect directive in Apache’s mod_alias documentation, checked September 27, 2026, works in .htaccess. The gone status returns 410 and takes no target URL:
Redirect permanent "/old-pruning-guide/" "https://garden.example/pruning-guide/"
Redirect gone "/spring-sale-2031/"
In nginx. The return directive in nginx’s rewrite module documentation, checked September 27, 2026, sends a status, optionally with a URL:
location = /old-pruning-guide/ { return 301 https://garden.example/pruning-guide/; }
location = /spring-sale-2031/ { return 410; }
The paths and domain are illustrative. If your host does not give you access to the nginx configuration, use its redirect tool or a WordPress plugin instead.
Plain 404. If you want a 404, trashing the page is usually enough and no rule is needed. If permalink guessing sends the old URL to a page you did not choose, add an explicit rule for it, or turn guessing off site-wide with the do_redirect_guess_404_permalink filter.
Clear the old URL from your own site
A retired URL that your site still links to keeps sending visitors and crawlers to a redirect or an error.
-
Sitemap. Open your sitemap and confirm the old URL is gone. A post that is still published but redirected with a per-post redirect field can stay listed. WP Visibility’s sitemap lists only published, indexable content, and saving, trashing, or deleting a post clears the sitemap cache; Submit Your Sitemap covers refreshing a stale file.
-
Internal links in content. Find links to the old URL and point them at the replacement, or remove them. The WP-CLI
search-replacecommand, checked September 27, 2026, has a--dry-runflag that reports matches without saving, and handles serialized data:wp search-replace 'https://garden.example/old-pruning-guide/' 'https://garden.example/pruning-guide/' --dry-runReview the report, back up the database, then run it again without
--dry-run. For a 404 or 410 with no replacement, edit the linking posts by hand instead. -
Menus, widgets, and patterns. Check Appearance > Menus or the Site Editor navigation, footer widgets, and synced patterns. These are stored outside the content of your posts and pages.
-
Other redirects. If older rules pointed to the page you just retired, point them at the final destination so they do not chain.
Verify the response
Check the old URL as an anonymous visitor:
curl -sI https://garden.example/old-pruning-guide/ | grep -i "^HTTP\|^location\|^x-redirect-by"
| Result | Meaning |
|---|---|
301 with the location you intended |
The redirect works. Now check that the target returns 200. |
301 to a different page |
Permalink guessing or another rule answered first. The x-redirect-by header, when present, names the software that sent it. |
404 or 410 |
The missing-page response works. |
200 |
The page is still published, or a cached copy is being served. Purge caches and check the post status. |
The X-Redirect-By header is set by WordPress’s wp_redirect() (checked September 27, 2026), which defaults it to WordPress and lets plugins name themselves; WP Visibility’s redirects send WP Visibility. Redirects made by the server or a CDN usually do not carry it.
In Search Console, once Google recrawls the old URL, a redirected one should move to “Page with redirect,” and one that returns 404 to “Not found (404)”; the help page does not say which item lists a 410. Google’s Page Indexing help describes the first as a URL that “will not be indexed,” while “the target URL of the redirect might or might not be indexed.” Both are the expected outcome of a retirement. If the redirect lands after more than one hop, see Redirect chains and loops.
