Redirecting 404 Error Pages to any page in WordPress

404’s are part of every website. In WordPress, most themes has a 404.php template file and WordPress will automatically use that page if a Page Not Found error occurs.

In this post, I’ll show you how to redirect 404 page to any page in WordPress.

Method #1

Open your 404.php file in your theme’s folder. If it doesn’t exist, then create a blank 404.php file. Paste the following code in there:

Here we are using php header() function for the redirect and all 404’s will be redirected to homepage with the get_bloginfo('url'). Change this to the page you want the 404’s be redirected to.

Method #2

The first method lets you edit your theme template file and this is not always a best practice. So here we are going to get a more handy and general approach with a simple php snippet that you only need to put to your functions.php.

Here we are using the wp action hook to preform the redirect. Also remember to replace get_bloginfo('url') with the page URL/function you want the 404’s be redirected to.


Author: Leo

My name is Leo who's behind this blog. I've been working with wordpress since 2010. I'll write about themes, plugins, tutorials and all about wordpress here. Hope you find it useful!

1 thought on “Redirecting 404 Error Pages to any page in WordPress”

Leave a Reply

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