WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Redirecting error 404 on home page

[Resolved] Redirecting error 404 on home page

  • 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?

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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.

    Thanks, I’ll remove it.

    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).

    “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!

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Redirecting error 404 on home page’ is closed to new replies.