Featured Articles

SEO Doctor FireFox Extension Review

SEO Doctor Firefox Extension is a SEO plugin developed by Vladimir Prevolac. The Extension has sever[...]

QuickPay & WP e-Commerce Integration

Integration module between QuickPay (Internet Payment Gateway) and the WordPress plugin, WP e-Commer[...]

No 404 on WordPress Blogs!

by Lars Koudal on 20/11/2009

51 views so far.

Share

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. 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.

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 :-)

Popular Searches
wordpress 404 redirect seo, wordpress 404 redirect to sitemap, how to redirect 404 wordpress, wordpress not directing to error page, "no 404 errors" & redirect to homepage, redirect my 404 errors, no 404 wordprerss redirect, error 404 Wordpress, wordpress error 404, wordpress blog/tag urls 404, 404 wordpress redirect, wordpress 404 unless exists, backlink booster 404, wordpress redirect all 404 errors on home page, redirect wordpress 404 homepage login, wordpress 404 redirect, 404 errors for tags i no longer have, wordpress no 404 page, wordpress multisite not creating directories 404 error,

{ 7 comments… read them below or add one }

Scriptdaily November 21, 2009 at 07:00

Thanks it’s great, i will try this

Reply

Kosta November 21, 2009 at 20:39

Very slick !

Tks

Kosta

Reply

Dave November 26, 2009 at 16:56

I think you left out the opening ‘<?' tag.

That code you gave won't work without it.

Even if I add that tag it still doesn't work.

Can you please post the full code needed to get this to redirect?

Thanks

Reply

Dave November 26, 2009 at 17:04

Hmm…

Did you guys get it working?

I tired adding that code but it didnt’ work.

I tried replacing the 404 page’s code with this but it fails to redirect and gives an error message.

I tried adding it to the existing code and it also failed.

I am pretty sure you’ve left some of the code out, such as the opening tag: ‘<?'

Even adding that tag to the code won't get it to work though.

Do I have to change any of that code to match the URL of my blog?

I don't understand what I am doing wrong.

Any additional info would be helpful thanks.

Reply

Dave November 26, 2009 at 17:24

OK, after a quick search I found a much easier way to do this. Simply add this to your 404 page:

and change the URL to your blog’s front page.

Simple and it works.

Reply

myWordPress November 27, 2009 at 04:14

Hi Dave

I think your comment included some code that was cut after you commented?

Reply

Danmark Bag Facaden December 15, 2009 at 06:07

on my blog i have my 404 error pages pointing to a overview over random feeds ( NyhedsLinks ), thats very usefull imo…

Reply

Leave a Comment

PRIVACY POLICY: Your privacy is important to us. We will never sell or rent your email address and you can unsubscribe at any time.

Previous post:

Next post: