Forums

ErrorDocument problem (10 posts)

  1. S.K
    Member
    Posted 7 years ago #

    The 404 error page is not displayed out of the theme folder after changing to crust-free permalinks using mod-rewrite and putting in a .htaccess file with the snippet shown on the admin page.

    I have a 404.php in my active theme folder, but it is not being called in 404 situations.

    Pl help me

    Regards
    S.K
    http://blog.cyberbrahma.com/

  2. James
    Happiness Engineer
    Posted 7 years ago #

    You need to add a line to .htaccess for this. Create the following line (using the correct path to your 404.php file) and add it to the .htaccess file in your site's root directory:

    ErrorDocument 404 /wp-content/themes/default/404.php

  3. S.K
    Member
    Posted 7 years ago #

    Thanks, macmanx.

    But why not the error page be called, like it does in the case of /index.php?error=404 is my question!

    When the query string is changed for other files, I think this 404.php also should be called likewise, as otherwise the paths to include files becomes a problem.

    Hope I have stated my problem properly.

    Thanks and regards
    S.K
    http://blog/cyberbrahma.com/

  4. Ryan Boren
    WordPress Dev
    Posted 7 years ago #

    ErrorDocument 404 /index.php?error=404

    With that, if a mod_rewrite rule is not matched, Apache tells WP to load the 404 page for the active theme. The ErrorDocument line is not added to .htaccess by default.

    If a mod_rewrite rule matches but the resultant query does not match any posts, WP loads the 404 template. If you use PATH_INFO permalinks and if either an internal rewrite rule doesn't match or a query doesn't resolve to any posts, WP loads the 404 template.

    There are several 404 scenarios, ErrorDocument in .htaccess only handles the case where no mod_rewrite rules are matched.

  5. S.K
    Member
    Posted 7 years ago #

    Correction :
    My blog URL:-
    http://blog.cyberbrahma.com/

  6. S.K
    Member
    Posted 7 years ago #

    Thanks rboren.

    <quote>If you use PATH_INFO permalinks and if either an internal rewrite rule doesn't match or a query doesn't resolve to any posts, WP loads the 404 template.</quote>

    But I use PATH_INFO permalinks. And I expect the 404 template from the active theme folder to be loaded (when 404 situation occurs), but it doesn't take place.

    Now, in dummy's terms, if PATH_INFO permaliks are opted, the default 404 template will not be loaded unless its path is defined in the errorDocument statement of the .htaccess file.

    Am I right in my postulate?

    Regards
    S.K

  7. James
    Happiness Engineer
    Posted 7 years ago #

    No, actually I quoted the wrong ErrorDocument rule. Sorry for the confusion. If permalinks are active, the .htaccess line should still be:

    ErrorDocument 404 /wordpress/index.php?error=404

  8. Tim Griffin
    Member
    Posted 7 years ago #

    ok,
    there has to be a simple thing I am missing.
    in .htaccess I have:
    ErrorDocument 404 /wp-content/themes/default/404.php

    the error I continur to get is:

    Fatal error: Call to undefined function: get_header() in ../../../../../../......default/404.php on line 1

    Help?

    Thanks!
    T

  9. Tim Griffin
    Member
    Posted 7 years ago #

    Ok,

    several attempts have resulted in success.
    .htacces required this:

    ErrorDocument 404 /index.php?error=404

    Now - no errors in the 404.php document!
    Yeah!

    How many hours can it take to work something so simple out?
    Well, it was fun anyway :-)

  10. cynics
    Member
    Posted 6 years ago #

    Hi guys, i tried the ErrorDocument 404 /index.php?error=404 solution, but what happens is if i have a link that goes like http://myhost.com/chicken - it'll show up a 404 page. but if i have a link that goes http://mohost.com/chicken.php - it says "No input file specified." and not the 404 page.

    if i didn't have the ErrorDocument line, the server won't redirect to the WP's 404 page in my theme but the generic 404 error message.

    any suggestions?

    thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags