301 Redirect to Custom 404page? AAAHHHH!

Community Forums Forums Design Tips and Tricks 301 Redirect to Custom 404page? AAAHHHH!

This topic is: not resolved

Tagged: , , ,

This topic contains 16 replies, has 3 voices, and was last updated by  Summer 9 months ago.

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #76795

    stepheniryna
    Participant
    Post count: 16

    Ideally I won’t ever have 404s. But just in case, I created a page and titled it “404page”. Added something like this in the htaccess:

    ErrorDocument 404 /404page.php

    This was supposed to circumvent the 404.php template and take people to “/404page” instead. It worked great.

    A few months later I am trying to do the same thing on another site. It doesn’t work. Then I go to the other site, and it no longer works there. All 423 articles I found on Google either talk about customizing a php (which I am unable to do in a way that looks like my other site pages), OR they include an htaccess line like the one above.

    Does anybody here know how to set this up?

    http://smallbusinessyou.com
    #76906

    nutsandbolts
    Moderator
    Post count: 3128

    Have you considered the Genesis 404 Page plugin? Much easier than all the redirects in my opinion.


    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    #76920

    stepheniryna
    Participant
    Post count: 16

    I’m not sure what you mean by “all the redirects”. It was only one line of code in the htaccess; it takes all 404 errors to the custom 404 page. Or, at least, it did.

    Another plugin… Maybe I will have a look at it. I’m just amazed that the answer is so elusive now.

    #76988

    Summer
    Participant
    Post count: 1071

    Have you tried making your .htaccess redirect a fully qualified URL?

    ErrorDocument 404 http://smallbusinessyou.com/404page.php


    #76990

    Summer
    Participant
    Post count: 1071

    Apparently, my replies are being eaten by the forums again :)

    Have you tried using a fully qualified URL for the redirect in your .htaccess file?


    #77009

    stepheniryna
    Participant
    Post count: 16

    Thanks for your reply Summer.

    Yes I have tried every url form imaginable (with .php and without, with trailing slask and without, with www and without). Something changed in Genesis and all of the 404 ideas I find (except plugin) are no longer working.

    I use Dynamik, and they make it easy to add templates in the child theme. So I copied the genesis 404 template and changed just the title (to experiment). But nothing changed on actual 404 page.

    Also I just found the code I used before. It was actually a modified 404 page template.

    <?php
    $URL= get_bloginfo('url');
    header("Location: http://www.mysitename.com/404page/");
    ?>

    I assume somebody who knows this stuff can see how this could work. Hopefully that same person can tell me why it does not work now :)

    #77044

    Summer
    Participant
    Post count: 1071

    That code tells me you had static page called “404page” inside WordPress. So theoretically, your /404page.php directive shouldn’t have worked, but I seem to recall something in WordPress where near matches would pull up a page… I ran into that problem with pages that should have returned 404s calling up pages with partial words in them, but they don’t do that anymore… I never dug into that to see why, so I don’t know for sure if that was a WordPress change, but I remember something along those lines changing between 3.5 and 3.6.

    So using that exact URL in your .htaccess file as you have it in that snippet should also have worked in your .htaccess file, IF that static page still exists at that URL.

    Is the URL you’re working on the one in your first post? Because that page does come up, but the text on it is unfinished. So if you put that URL in your .htaccess file, and test it by going to a URL on your site you know doesn’t exist, that 404page URL should come up for you.


    #77052

    stepheniryna
    Participant
    Post count: 16

    Yes, that is a page called “404page” inside wordpress. And yes, that url is the one I’m working on.

    That code worked great when I got it, and it was only a couple of months ago. I have seen the same code on other sites. Here’s one:

    http://www.wphike.com/170/how-to-create-custom-404-error-page-in-genesis-framework/

    That static page still exists, but the htaccess line doesn’t change anything. And I have seen that line of code (htaccess) all over the web. Not sure why it’s not working. I’ve been testing like you said; just doesn’t work.

    For now I just took it out of there so that I don’t mess something up.

    #77074

    Summer
    Participant
    Post count: 1071

    Well, when I try to access that page now, I get this error:

    Parse error: syntax error, unexpected '(', expecting T_VARIABLE or '$' in smallbusinessyou.com/wp-content/uploads/dynamik-gen/theme/custom-functions.php on line 50

    And if I go to a URL that generates a 404 error, a 404 page does come up. Which page are you trying to have be your 404 page, and what error were you getting before?


    #77075

    Summer
    Participant
    Post count: 1071

    Well, when I try to access that page now, I get this error:

    Parse error: syntax error, unexpected ‘(‘, expecting T_VARIABLE or ‘$’ in smallbusinessyou.com/wp-content/uploads/dynamik-gen/theme/custom-functions.php on line 50

    And if I go to a URL that generates a 404 error, a 404 page does come up. Which page are you trying to have be your 404 page, and what error were you getting before?


    #77076

    Summer
    Participant
    Post count: 1071

    FFS, why is the forum eating every post I submit that has code quoted in it?

    Anyway, your custom 404page is generating a PHP syntax error, while a regular not found destination is pulling up a generic 404 page.

    What is it exactly that isn’t working?


    #77085

    stepheniryna
    Participant
    Post count: 16

    uh… (glazed look in eyes), I don’t know what you just said.

    All I want is:

    1) I type in mysite.com/wrong-url
    2) some little gnome in my computer takes me to mysite.com/404page (the one I created in wordpress)

    #77124

    Summer
    Participant
    Post count: 1071

    I was curious about the PHP syntax error, but that seems to be fixed now.

    So, the destination you want all error pages to use is http://smallbusinessyou.com/404page/ right?

    Right now, if I use a bogus URL to that domain, it comes up with a default 404 page, which means that another template or a default template is in the mix somewhere.

    There are several ways to change this.

    First, make sure there is no 404.php template in your theme folder, and that any 404 plugins or other 404 redirects are disabled.

    Then, make sure the ErrorDocument directive in htaccess uses the complete URL, http://smallbusinessyou.com/404page/

    or… take the content from that 404page page, and make it the content of your 404.php template, and remove the ErrorDocument directive from your htaccess file and unpublish that page.


    #77125

    Summer
    Participant
    Post count: 1071

    I was curious about the PHP syntax error, but that seems to be fixed now.

    So, the destination you want all error pages to use is http://mysite.com/404page/ right? (for some reason these forums are not posting my posts using your smallbusiness URL)

    Right now, if I use a bogus URL to that domain, it comes up with a default 404 page, which means that another template or a default template is in the mix somewhere.

    There are several ways to change this.

    First, make sure there is no 404.php template in your theme folder, and that any 404 plugins or other 404 redirects are disabled.

    Then, make sure the ErrorDocument directive in htaccess uses the complete URL, http://mysite.com/404page/

    or… take the content from that 404page page, and make it the content of your 404.php template, and remove the ErrorDocument directive from your htaccess file and unpublish that page.


    #77130

    stepheniryna
    Participant
    Post count: 16

    Figured out solution. View source of “/404page”. Copy all. Open Dynamik custom > templates. Add new. Title “404″ (this is a php page). Select “wordpress page” instead of “page template”. Paste all. Save. Done

    Now all 404 errors show the exact mirror of my “/404page” in wordpress.

    No plugin necessary.

    Thanks everybody for the attempts to help.

    Now if I could only figure out this smooth scrolling to anchors… I’ll post if not.

Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic.