1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to f@ckin 404 redirect to main page in wordpress

Discussion in 'WordPress' started by pary07, Oct 4, 2008.

  1. #1
    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 : ?>
     
    pary07, Oct 4, 2008 IP
  2. aj.eylia

    aj.eylia Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    create a new 404.php
     
    aj.eylia, Oct 4, 2008 IP
  3. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Cash Nebula, Oct 4, 2008 IP
  4. That-Guy

    That-Guy Peon

    Messages:
    452
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I am having this problem but the plugin does not re-direct back to the main page. Can anyone help?
     
    That-Guy, Aug 1, 2009 IP
  5. adbox

    adbox Well-Known Member

    Messages:
    906
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    155
    Digital Goods:
    1
    #5
    Looking for this as well.
     
    adbox, Dec 8, 2009 IP
  6. ilook

    ilook Well-Known Member

    Messages:
    1,602
    Likes Received:
    15
    Best Answers:
    1
    Trophy Points:
    165
    #6
    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.

    :)
     
    ilook, Dec 8, 2009 IP
    kevoh99 likes this.
  7. tonytovar

    tonytovar Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    GENIUS! PURE GENIUS! This Worked!!!! :D

    Thank you!
     
    tonytovar, Dec 11, 2009 IP
  8. adbox

    adbox Well-Known Member

    Messages:
    906
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    155
    Digital Goods:
    1
    #8
    *nods@ilook thank you
     
    adbox, Dec 11, 2009 IP
  9. ilook

    ilook Well-Known Member

    Messages:
    1,602
    Likes Received:
    15
    Best Answers:
    1
    Trophy Points:
    165
    #9
    Glad it helped guys :)
     
    ilook, Dec 13, 2009 IP
  10. Wp-Mod.Com

    Wp-Mod.Com Peon

    Messages:
    381
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #10
    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
     
    Wp-Mod.Com, Dec 13, 2009 IP
  11. mccomf

    mccomf Active Member

    Messages:
    517
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #11
    This is working like a charm...
     
    mccomf, Apr 13, 2010 IP
  12. KimiGermany

    KimiGermany Peon

    Messages:
    1,117
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Hi folks, may be this thread will help?

    forums.digitalpoint.com/showthread.php?t=1765914
     
    KimiGermany, Apr 13, 2010 IP
  13. slimjim2010

    slimjim2010 Peon

    Messages:
    245
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Thanks!

    This 404 code works great!
     
    slimjim2010, May 23, 2010 IP
  14. ilook

    ilook Well-Known Member

    Messages:
    1,602
    Likes Received:
    15
    Best Answers:
    1
    Trophy Points:
    165
    #14
    It's already solved by my solution posted above :)
     
    ilook, May 27, 2010 IP
  15. kevoh99

    kevoh99 Peon

    Messages:
    175
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    That sounds really interesting. Will try it on my blogs. I have already added to your user reputation. Thanks
     
    kevoh99, May 27, 2010 IP
  16. ilook

    ilook Well-Known Member

    Messages:
    1,602
    Likes Received:
    15
    Best Answers:
    1
    Trophy Points:
    165
    #16
    Thanks Kevoh99 :)
     
    ilook, May 27, 2010 IP
  17. hardjoko

    hardjoko Active Member

    Messages:
    357
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #17
    Is there a plugin for this? Just curious.
     
    hardjoko, Jun 1, 2010 IP
  18. adbox

    adbox Well-Known Member

    Messages:
    906
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    155
    Digital Goods:
    1
    #18
    adbox, Jun 1, 2010 IP
  19. thavara

    thavara Peon

    Messages:
    231
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #19
    use 404 redirection plugin, so simple
     
    thavara, Jun 2, 2010 IP
  20. piwacket

    piwacket Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    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.:confused:
     
    piwacket, Oct 30, 2010 IP