If you are like me, and you try out different things on your WordPress blogs, you are sometimes in a situation where you have a ton of redirects to do.

You could be changing permalink structure on an established blog, or you could be moving to new hosts, forgetting some posts or tags.

Whatever the reason, you have a few options regarding 404 errors. Not sure what that is?  What are 404 errors?

A 404 error is what occurs if you go to a post/page/tag/whatever, that no longer exists. Many WordPress Themes have a separate page for this situation, and you can tweak it accordingly. There is a problem, however, the link will still return a 404, and this will affect your ranking in the search engines.

Going through these manually and setting up redirects in your .htaccess or using a plugin such as Redirection (one of my favorite SEO WordPress Plugins) takes time, and you have to know what you are doing.

If you just want to make sure there are no leaking holes in your WordPress blog, that looses linkjuice for you, there is a very quick way for you to take care of this.

  • Go to the folder of your WordPress Theme
  • Does it have a file named “404.php”? If not, create one, if it does, consider using below code instead.
  • Open up the 404.php and fill in the following code:
<?php $url=bloginfo('url'); header("Location: $url ",TRUE,301); ?>

So, what is going on? Whenever a 404 error occurs, WordPress first tries to look in the WordPress Theme’s folder, to look for a 404.php file. If that does not exist, a 404 error is returned, and then an error page is displayed. This varies based on your server/host and .htaccess.

You can also read automatic 301 redirects for spam pages.

Notes:

This is the quick, fast and easy way to make a 301 redirect on all 404 pages on your WordPress blog. However, it does not register anything, and it only directs the “linkjuice” from the sites linking to you to your front page. If you wish to direct that linkjuice to some other place, you will have to edit the code.

Have fun 🙂

Error: Please enter a valid email address

Error: Invalid email

Error: Please enter your first name

Error: Please enter your last name

Error: Please enter a username

Error: Please enter a password

Error: Please confirm your password

Error: Password and password confirmation do not match