WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Redirecting error 404 on home page (6 posts)

  1. cryonics
    Member
    Posted 6 years ago #

    I have tried to redirect 404 error (page not found) on the home:

    RewriteEngine on
    ErrorDocument 404 /index.php

    but this is redirected to an error page with this message:
    "Sorry, no posts matched your criteria."

    I want to display the home instead.

    Is it a mean to to that?

  2. moshu
    Member
    Posted 6 years ago #

    If you don't have a 404.php INSIDE your theme folder - WP displays the main (index) page when page not found, without you messing with the htaccess.

  3. cryonics
    Member
    Posted 6 years ago #

    Thanks, I'll remove it.

  4. cryonics
    Member
    Posted 6 years ago #

    I do not have a such file (I use the classic theme).

    I have even searched the "Sorry, no posts matched your criteria" sentence in source code and found it in no file.
    This could come from the database?

    Can I add a 404.php file and link it somewhere (it could redirect to the home).

  5. cryonics
    Member
    Posted 6 years ago #

    "If you don't have a 404.php INSIDE your theme folder - WP displays the main (index) page when page not found, without you messing with the htaccess."

    Not for me.

    I have put this code into a file named 404.php :

    <?php
       header("Status: 301 Moved Permanently");
       header("Location:http://www.xxxxxx.tld");
    ?>

    (xxxxxx.tld is my domain name).

    I have stored 404.php into /wp-content/themes/classic/

    and that works! Thanks to myself!

  6. Anonymous
    Unregistered
    Posted 6 years ago #

    thanks for the php redirect code, this worked like a charm for me!

Topic Closed

This topic has been closed to new replies.

About this Topic