How To Create A 404 Error Redirect For WordPress

There are several different solutions for a 404 error page or redirect with a WordPress site or blog. A 404 error is when a URL on a domain is not found or available. If you play around enough with WordPress themes you will see that WordPress theme authors will use many different solutions for a 404 error page. Some are a bit more user-friendly than others, and some unscrupulous theme authors will even redirect your visitors to their website with a 404 error redirect.

The latter I spoke about is how I learned to make a 404 error redirect to a specific URL. In regard to the case I spoke about above, someone contacted me to teach them how to upload a few “custom” PLR WordPress themes they had purchased. First, let me say that these themes were total junk and just a modified version of the default theme with a different header graphic (that needed to be edited) and of course the seller’s links embedded all throughout the theme. Don’t get me wrong a good WordPress theme author should have a link in at least the footer in return for the free theme. But in this case, it was like stealing traffic, especially for such a crappy theme. It wasn’t bad enough that the links were scattered throughout the theme, the theme actually redirected the visitor away from the blog if a 404 error occurred.

Here is how easy it is to do if your theme has a 404 error template file (404.php) and you want to specify an actual URL to redirect your visitors to for the 404 error. Simply use this code in the entire 404.php file and then specify the actual URL:

<?php
header( ‘Location: http://www.ChangeToActualURL.com’ ) ;
?>

There are other methods and solutions like on this site, at the time of this post, it redirects to a page that offers to search the site, or click some AdSense ads, hey I have kids to feed! This is done using code that is actually within the main index file instead of a separate 404.php file. There are so many different WordPress themes and each author has their own idea of a 404 error page so I can’t possibly give solutions for each method in this post. But you should make sure your visitors are not getting hijacked by a pirate WordPress theme author or theme reseller!

Disclosure: Some of the links in this article are affiliate links and we may earn a small commission if you make a purchase, which helps us to keep delivering quality content to you. Here is our disclosure policy.

Editorial Staff
Editorial Staff
Editorial Staff at WPArena is a team of WordPress experts led by Jazib Zaman. Page maintained by Jazib Zaman.

LEAVE A REPLY

Please enter your comment!
Please enter your name here
Captcha verification failed!
CAPTCHA user score failed. Please contact us!

spot_img

Related Articles

How to Reduce WordPress Registration Spam

WordPress forms offer a valuable chance for you to connect with your website visitors and potential customers. Those people may...
Read More
Why WordPress is the best CMS? Having a website has become a necessity for both individuals and businesses. Content Management...
When optimizing the speed of your WordPress site, you might come across a performance metric known as Time to First...