Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

What plugin will allow me to redirect 404 errors to a specific WP page...and track all 404 errors?

I'd like to just use a plugin that will redirect without having to edit templates and such.

share|improve this question
add comment

2 Answers

You can make a 404 page by creating a file in your theme called 404.php and filling that with whatever you want to be shown on a page that WordPress can't find. You can read more about Creating an Error 404 Page in the Codex.

Alternatively if you wanted to redirect users back to your home page instead you could create a 404 file in you theme as above with the following:

 <html>
 <head>
     <meta http-equiv="refresh" content="5; url=<?php echo home_url(); ?>/">
     <title>404 - Page not found</title>
 </head>
 <body>
     <h1>Error 404 - Sorry the page you are looking for could not be found</h1>
     <h2>You will be redirected to the homepage in a few moments.</h2>
 </body>
 </html> 
share|improve this answer
    
Well, I created a regular page in WP and I would like users to find this page which uses a template from my theme....instead of a 404. –  dreamgrowers Oct 2 '11 at 4:39
    
You could use the above code, but change the countdown to 0 and replace the url with <?php echo get_permalink(1); ?> where 1 was the page ID you want to redirect users to. –  Jono Warren Oct 2 '11 at 10:06
    
I really like what you're saying! So...Where is the countdown? Would you mind posting the entire code you recommend for redirecting to a specific wordpress page? –  dreamgrowers Oct 9 '11 at 7:22
add comment

add these to your function.php

add_action( 'template_redirect', 'custom_redirect', 1 );
function custom_redirect() {
    $direction = get_permalink( 12 ); // Or whatever the page_id is ...
    if ( is_404() ) wp_redirect( $direction );
}

There. But it still not tracking the 404 errors. Unless you add more specific codes in the function which counts all the redirection or on the destination page for the same purpose.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.