skip to Main Content

How to serve a 410 response code with WordPress

I thought it would be interesting to write about a fun, technical SEO topic: How to serve a 410 response code with WordPress. If you’re familiar with SEO, you know that it’s best to implement a 301 redirect to a new page, for a page that’s been retired (deleted). But, what do you do when you can’t? What do you do when you can’t 301 redirect to a replacement page, because of the situation. In this article I’m going to share how to serve a 410 response code with WordPress, when you should do this, and why.

What is a 410 response code?

Whenever a client, such as a web browser or search engine crawler (also called a web crawler, spider, or simply crawler), makes a request to a server, the server will send back an HTTP response code. There are five categories of HTTP response codes, and each category has several codes within it, with each code having a specific meaning. In this article, we’ll touch on only two response codes in the 4xx category, and more specifically, the 410 response code.

The 4xx category indicates there was a problem with the request. More specifically, a 410 response code is served to a client when the page has been deleted, permanently, and with no redirection or forwarding is in place. The difference between a 404 response code and 410 response code, is that a 404 response code indicates the server couldn’t find the resource, whereas the 410 response code indicates the resource was deleted from the server intentionally by the webmaster. For search engine crawlers, like Googlebot or Bingbot, serving a 410 response means you’ve intentionally and deliberately removed a page, and that you’re requesting it be cleared from the cache and removed from the index. This request is essentially asking search engines like Google, Bing, and others, to not show the page in search results ever again.

A note about how these responses are treated differently by search engine crawlers

When a search engine receives a 404 response, web crawlers will typically try multiple times to access the URL, over time, to see if the resource can be crawled, rendered, and indexed. Sending a 410 response to a web crawler tells the crawler that the page is gone and that they shouldn’t come back to the URL again. So, are you sure you want to send that response? This is why setting up a 410 response for a page should be well though out and planned carefully.

410 vs. 404: When you should set up a 410 and why

In most scenarios, letting a page 404, which is a simpler way of saying let the server return a 404 response, when there isn’t a content replacement is okay. Ideally, when you are retiring a page you have a replacement ready to go, and upon retiring the page, you 301 redirect it to its replacement. We like using the Redirection plugin for that scenario because it makes setting up redirects a breeze (at the time of publishing this article, of course). Sometimes, however, this isn’t possible. Maybe the service can’t be offered anymore. Maybe a product won’t be offered going forward. Whatever the scenario is, sometimes you need to retire a page with no placement. When a page needs to come down, and there’s no replacement, usually, you can let it 404.

Maybe one day you’ll find yourself in a scenario where you want to speed up the process of removing a page from search engine indices and search results altogether. Maybe you have a team member or a manager with an urgent request or some other scenario. When you need a page to be removed as quickly as possible, that’s when you’ll want to send a 410 response. The good thing is that using WordPress makes this task pretty easy.

How to set up a 410 response code in WordPress

In the steps below, I’ll show you how to set up a 410 response code, sometimes called a 410 error page, with WordPress. I’ll show you how to do complete this task, covering a few different scenarios.

How to set up a 410 response code with Yoast SEO Premium

What might be the easiest and simplest way to set up a 410 response in WordPress is with the Yoast SEO Premium plugin. Yes, premium. That means you’ll have to subscribe to Yoast SEO Premium to access this option. Having said that, with Yoast SEO Premium, you’re able to set up a 410 header fast and easy. This function will send a 410 response to any client requesting a URL, including crawlers.

If you’d like to spare the expense and take on the task using non-paid options, keep reading.

How to set up a 410 response code with Yoast SEO

While Yoast Premium SEO might offer the easiest option, it isn’t the only way to leverage Yoast to set up a 410 response code for a page. With Yoast’s file editor, you’ll be able to access the .htaccess file and add a 410 response using that method.

How to set up a 410 response code with Yoast SEO:

  1. Log in to WordPress.
    Note: With these steps, I’ve assumed you’ve already installed Yoast SEO.
  2. Navigate to SEO > Tools.
  3. Select File editor.
    Note:
    If you don’t see this option, you’ll need to enable file editing before proceeding.
  4. Scroll down to .htaccess file.
    .htaccess section in Yoast's file editor
  5. Click the field and on a new line, add the following code:
    Redirect 410 [page path]
  6. Select Save changes to .htaccess. That’s it. You’re all set.

There are a couple of things to call out when using the steps above. Let’s first talk about syntax or the format you need to use to make sure the 410 response is set up correctly. The syntax is straightforward:

Redirect 410 [page path]

What this simple line of code does is exactly what we’re trying to do: Any client requesting the path defined will instead receive a 410 response code.

Let’s look at an example. Let’s say I wanted to 410 my contact page (which no one should do, ever):

Redirect 410 /contact/

In the example shown, I’m telling the server that any client going to /contact/ should receive a 410 response.

You’ll also want to use a new line for each page path. Multiple pages should not be on the same line.

Let’s say I wanted to 410 not only my contact page but also my services page (madness, right?).

Here’s what that would look like in the .htaccess file:

Redirect 410 /contact/
Redirect 410 /services/

How to set up a 410 response code without a WordPress plugin

Below, I’ll show you how to add a 410 header to your .htaccess file directly:

  1. Log in to your hosting account.
  2. Access cPanel.
  3. Access the file manager.
  4. Select the public_html folder.
  5. Select the .htaccess file.
  6. Select Edit.
  7. Add the page you want to 410, using the syntax below:
    Redirect 410 [page-path]

    Example:

    Redirect 410 /blog/awesome-product-review/
  8. Save the file. That’s it. You’re all set.

Wrap up

If you can use a 301 redirect, use a 301 redirect. If you can retain the content on your website, that’s best for your SEO. Using a redirect to get visitors to a page that serves the same purposes as the previous page is ideal, short-term, and long-term. In that rare case when you aren’t going to or can’t replace a page, setting up a 410 response code in WordPress might be your next best option. Remember, this should only be done if you absolutely have to retire a page and can’t replace it, and the situation calls for 410 error. In most cases, a 404 is perfectly fine, but there are some cases where a 410 is useful.

If you need help fixing 404 errors or managing redirects for your WordPress website, contact us. We’d love to help!

Josh Gellock

Josh is the SEO and Content Strategist at Expander Digital, an SEO studio he founded in 2014. He's been in the SEO space since 2011 and helps businesses manage their SEO through projects, consultations, and campaigns. When he’s not meeting with clients, you can find Josh spending time with his children or on a bike.

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top