Wasted like 3 hours in finding this one out I have loads of 404 pages on my wp blog. And I want to redirect all of them to my home page. How can I do this ? The htaccess method won't work .. Doing php redirect from my themes' index.php file won't do it as the the index.php first calls the header and using this code when there is no post(in case of 404 errors) gives the error while implementing the standard php redirect i.e <?php header("Status: 301 Moved Permanently"); header("Location:http://www.ChangeThisURL.com"); ?> Code (markup): The error on 404 page in wordpress - Warning: Cannot modify header information - headers already sent by (output.. blah blah Code (markup): The wp theme doesn't have its own 404.php error page and 404 in handled in the index.php only through function <?php else : ?>
I use this code and does the job for me. When a visitor enters a dead link on one of my sites, it gets automatically redirected to the root (www.domain.com) <?php //Simple Redirect for WordPress. //Christopher Carey //301 Redirect for Wordpress //http://wwww.noheat.com header("HTTP/1.1 301 Moved Permanently"); header("Location: ".get_bloginfo('url')); exit(); ?> PHP: Make a php file and name this file "404.php" and upload this in the theme folder via FTP (NOT in your plugins folder!) If there is already a 404.php file simply overwrite it with the new one.
i have been working around wordpress lately and this error that you get about headers sent out is mostly due to the white space above and below php closing an opening tags, so be careful , dont leave any space
That sounds really interesting. Will try it on my blogs. I have already added to your user reputation. Thanks
In wordpress did the 404 redirect in 404.php as shown in this thread... I get to main page but the relatively linked images have the erroneous "stub" in them... There may be some OTHER config problem... I'm flummoxed. Any help/advice appreciated.