Wordpress :: HELP!! Losing visitors on 404 page.

Discussion in 'WordPress' started by Nite, May 9, 2008.

  1. #1
    I'm using wordpress v2.5.1, and Google has some pages in its search results that take people to the 404 page. Now, on the 404 page, I would like search to be performed (automatically) based upon the words in the title link that they used on Google to enter my site.

    For example, say someone found my site on Google while searching for the keyterm, "X" . As it is now, when they click on that Google link to my site, they are taken to the 404 page because the link to "X" wasn't found. However, I know that there are other posted related to "X" present and active -- most likely in the site archive.

    How would I put up a list of related posts, relating to "X" on the 404 page to help people find what they were looking for?
     
    Nite, May 9, 2008 IP
  2. Nite

    Nite Active Member

    Messages:
    440
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    68
    #2
    Nite, May 9, 2008 IP
  3. godsofchaos

    godsofchaos Peon

    Messages:
    2,595
    Likes Received:
    124
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Google surely loves Dp! And it should cause Dp is a good forum. And for your issue, you need to set up a 301 redirect :) Just google 301 redirect set up on wordpress girly! If you still cant find anything, just let us know here again and we will surely try to help. :)
     
    godsofchaos, May 9, 2008 IP
  4. Nite

    Nite Active Member

    Messages:
    440
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    68
    #4
    Well, I suppose that I'm wondering how to pass along the search term from Google into my blog in order to display 5 or so links to posts about the search term. I don't want to substitute the 404 header for a 301 header because I do want older information to die and go away ... however, I don't want to lose human readers because of a boring and information-less 404.
     
    Nite, May 9, 2008 IP
  5. godsofchaos

    godsofchaos Peon

    Messages:
    2,595
    Likes Received:
    124
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hmmm very reasonable 'reason' to say the least. Which exact page is showing that? You know my site was showing that too, but thankfully they were all author pages and I simply added no follow to them. However since its an issue with the posts, can you post the linky? Maybe its a problem with the theme itself, which theme are you on? I'm asking all these cause I'm talking from my mobile and really cant properly see the full version of your blog.
     
    godsofchaos, May 9, 2008 IP
  6. godsofchaos

    godsofchaos Peon

    Messages:
    2,595
    Likes Received:
    124
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Also you can do a turnaround thing, and list your archives page within the 404 page? Will that work?
     
    godsofchaos, May 9, 2008 IP
  7. apachehtaccess

    apachehtaccess Guest

    Messages:
    82
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #7
    apachehtaccess, May 9, 2008 IP
  8. Nite

    Nite Active Member

    Messages:
    440
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    68
    #8
    Interesting.

    However, consider this scenario. Someone browsing the internet finds my site. They visit my site through the google link. The Google link brings them to the 404 page. With this plugin, it appears that more Google search results would be displayed on the 404 page as possible alternatives.

    Now, what if those alternatives linked to more pages which are 404 ? The internet surfer would be frustrated at finding the 404 page to begin with and frustrated again when the "solution" bring him or her to another 404 page.

    I would be nice if the keyterm bringing them to my site would be passed through the blog's built-in search engine and listed as "Closely related links" . I think Google could be made aware of those closely related links in association with the 404..
     
    Nite, May 9, 2008 IP
  9. n-james

    n-james Well-Known Member

    Messages:
    1,367
    Likes Received:
    70
    Best Answers:
    0
    Trophy Points:
    165
    #9
    Why don't you just redirect the 404 page to your home page?
     
    n-james, May 9, 2008 IP
  10. Nite

    Nite Active Member

    Messages:
    440
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    68
    #10
    Because a redirect (301) would not tell the search engines to remove older content. A 404 will get older links out of the search engines results ... eventually. A 301 will simply keep all "not found" links alive.
     
    Nite, May 9, 2008 IP
  11. apachehtaccess

    apachehtaccess Guest

    Messages:
    82
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #11
    If you don't want your 404's indexed by google then add this to your header.php

    <?php if(is_404())echo '<meta name="robots" content="noindex" />';?>
    Code (markup):
    Another thing: When a request to wordpress is made for a non-existing post, it is run through the file canonical.php which automatically tries to find the requested post, using mispellings etc..

    And really for SEO you shouldn't allow google to index your 404 pages. It could very well be that your blog is not returning the proper 404 Not Found http status code, which is a big problem in my humble point of view. You can check your blog for this with this http header viewer

    OK! I just took a 20minute break from writing this reply to go update the plugin.. I've just released version 4.4 (should show up in about 20minutes when svn repos update) which includes a new function that displays related posts on your blog! It searches for related posts using the keywords it finds from the requested url, and displays those as well as the google search. This fixes your question I believe? Thanks for the tip!
     
    apachehtaccess, May 9, 2008 IP
  12. Nite

    Nite Active Member

    Messages:
    440
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    68
    #12
    WOW!

    :D :D :D

    I can't wait to take it for a spin!
     
    Nite, May 9, 2008 IP
  13. Nite

    Nite Active Member

    Messages:
    440
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    68
    #13
    Ok, what I did was this in header.php

    
    <?php if(is_404())echo '<meta name="robots" content="noindex" />
    '; else echo '<meta name="robots" content="follow, all" />
    '; ?>
    
    Code (markup):
    In this manner, all pages except for 404 pages will be indexed.
     
    Nite, May 9, 2008 IP
  14. Nite

    Nite Active Member

    Messages:
    440
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    68
    #14
    Is it possible to strip out the category name from the permalink on the inbound link (e.g., "/category/the-post-inside" ... becomes "the-post-inside") and transform the dashes to spaces (e.g., "the-post-inside" becomes "the post inside")?

    Right now, the category name, and all URI information, is automatically placed in the Google search bar. Is there any method to remove the category (or everything up until the slash), and transform the dashes? Thanks.
     
    Nite, May 10, 2008 IP
  15. Nite

    Nite Active Member

    Messages:
    440
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    68
    #15
    Ok, here's what I'm attempting to do on the 404 page.

    
    <?php  
    $search_term = substr($_SERVER['REQUEST_URI'],1);  
    $search_term = urldecode(stripslashes($search_term));  
    $find = array ("'.html'", "'.+/'", "'[-/_]'") ;  
    $replace = " " ;  
    $search_term = trim(preg_replace ( $find , $replace , $search_term ));  
    $search_term_q = preg_replace('/ /', '%20', $search_term);
    ?>
    
    Code (markup):
    What that code is supposed to do is capture the inbound link from the search engine, remove the slashes and the dashes, and create a new "wordpress friendly" search phrase for the search engine built into wordpress.

    I would love to prefill the search bar with the new search string..

    
    <p>
    <form method="get" id="searchform" action="http://WWW.MYSITE.COM/">
    <div>
    <input type="text" value="<?php echo $search_term_q; ?>" name="s" id="s" >
    <input type="submit" id="searchsubmit" value="Search" >
    </div>
    </form>
    </p>
    
    Code (markup):
    Can anyone spot what would be wrong with the first php coding? I can't seem to pass the value of $search_term_q to the search bar automatically.
     
    Nite, May 11, 2008 IP
  16. Nite

    Nite Active Member

    Messages:
    440
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    68
    #16
    Ok, I found some code on the 'net, and it helped me with what I wanted to do. This code will remove slashes and dashes.

    
    <?php
    
    $uri = $_SERVER['REQUEST_URI'];
    $uri = rtrim($uri, '/');
    $new_string = str_replace("/", " ", $uri );
    $final_string = str_replace("-", " ", $new_string);
    
    ?>
    
    Code (markup):
    And the new string will be placed inside a search box automatically, ... now the user has to click the search button.

    
    <p>
    <form method="get" id="searchform" action="http://WWW.MYSITE.COM/">
    <div>
    <input type="text" value="<? echo $final_string; ?>" name="s" id="s" >
    <input type="submit" id="searchsubmit" value="Search" >
    </div>
    </form>
    </p>
    
    Code (markup):
    Now the goal is to run that newly formatted string and run an automatic search on it and display it on the page as a "You might have been looking for this..."
     
    Nite, May 11, 2008 IP
  17. AidenChong

    AidenChong Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    But I have a question here. I checked my WP blog directory in my account, I found 2 files with the name header.php. The first one was being located in my /blog/ directory, named [ wp-blog-header.php ] , and the other one was being located in my /themes/THEMESNAME/ directory, named [ header.php ] .. So which one should I add the code quoted above into ?

    Thanks in advance for your help.
     
    AidenChong, May 14, 2008 IP
  18. Nite

    Nite Active Member

    Messages:
    440
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    68
    #18
    I would start off with the one located in your themes directory. After you change something and save it, reload the page and browse the page's source code to identify the changes.
     
    Nite, May 14, 2008 IP
  19. apachehtaccess

    apachehtaccess Guest

    Messages:
    82
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #19
    @AidenChong

    Nite is right! Never modify any files other than the ones in your theme and plugin directory, those are wordpress core files, and shouldn't be modified unless you know what you are doing.

    @Nite

    Heres what I am actually using:

    if(is_home() && !is_paged())$aa_robot_meta='<meta name="robots" content="noydir,follow" />';
    else if(is_paged()) 		$aa_robot_meta='<meta name="robots" content="follow" />';
    else if(is_search())		$aa_robot_meta='<meta name="robots" content="noindex,nocache,follow" />';
    else if(is_page())		$aa_robot_meta='<meta name="robots" content="noydir,follow" />';
    else if(is_single())		$aa_robot_meta='<meta name="robots" content="noydir,follow" />';
    else if(is_category())        $aa_robot_meta='<meta name="robots" content="noindex,follow" />';
    else if(is_404())		$aa_robot_meta='<meta name="robots" content="noindex,follow" />';
    echo $aa_robot_meta;
    Code (markup):
     
    apachehtaccess, May 14, 2008 IP
  20. AidenChong

    AidenChong Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Thanks @Nite @apachehtaccess , for clarifying my doubts.

    By the way, apachehtaccess, I have downloaded your wordpress 404 pages plugin, and you seems to have a very interesting blog too, keep up the good work, my friend..

    Will visit your forum soon :)
     
    AidenChong, May 15, 2008 IP