admin-plugins author calendar category facebook post rss search twitter star star-half star-empty

TIDY REPO

The best and most reliable WordPress plugins

Free

Redirect 404 Error Page to Home Page or Custom Page

Plugin Author: WebFactory

Gordan Orlic

May 31, 2018 (modified on July 21, 2018)

SEO

Every once in a while we run into a plugin that’s so simple that it can’t be any simpler. It performs just one function and has barely any options. Does that make it a bad plugin? Definitely not! It focuses on and tackles one problem, and that’s great to see in a world where we often see “one plugin does it all” approaches.

What’s it Do?

Like the name clearly states, this plugin will redirect all visits to nonexisting 404 pages to a custom page or the site’s homepage. That’s it. Honestly not much more to say. Also, not much more to see if you have a look at its clean source code. A total of 74 lines with comments, blank lines and all other “fluff”. If you want to include the plugin’s functionality in your functions.php or some other plugin this is the core of the code:

add_action('wp', 'redirect_404', 1);

function redirect_404() {
  if (is_404()) {
    $redirect_slug = '/my-404-page/';
    wp_redirect(home_url($redirect_slug), 301);
    exit;
  }
} // redirect_404

The two plugin’s settings are located in Settings -> General. As soon as you activate the plugin, it starts redirecting 404 pages to the home page. If you want a different page, set a custom URL. You can also choose between a permanent 301 redirection or a temporary 302 one.

Do I need it?

SEO wise some may question the quality of this plugin. Once it’s activated, your site will no longer return a 404 status code for any page. Instead, it will do a 301 or 302 redirect from the nonexisting page to the designated “404 page” which is not a 404 page because it will return a status of 200.

Many SEO experts cringe upon solutions like the one offered by this plugin, but for a temporary solution, a smaller site, or a situation where you have lots and lots of nonexisting pages this is an excellent, super-fast fix that just works. And we like plugins that just work!

Did you like this plugin?

Plugin Info
  • Downloads: 24,517+
  • Downloads trend (30d): +864.2%
  • Active installations: 6,000+
  • Rating:
  • Last Update: August 9th, 2018
  • Download Plugin for Free