cryonics
Member
Posted 4 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?
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.
cryonics
Member
Posted 4 years ago #
cryonics
Member
Posted 4 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).
cryonics
Member
Posted 4 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!
Anonymous
Unregistered
Posted 3 years ago #
thanks for the php redirect code, this worked like a charm for me!