normally with a 404 error the site will be redirected to theme/404.php. I'd like to the home page instead. I tried
ErrorDocument 404 http://www.example.com
but it doesn't work. How can I solve this issue?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communitynormally with a 404 error the site will be redirected to theme/404.php. I'd like to the home page instead. I tried
ErrorDocument 404 http://www.example.com
but it doesn't work. How can I solve this issue?
A 404 should never be a redirect. A redirection status begins with 3
, not with 4
.
You can either include the index.php
(or home.php
or front-page.php
) in your 404.php
or just remove the 404.php
from your theme. Then WordPress will use the index.php
.
404.php
file will show the index.php
. Have you tried it?
Oct 8, 2015 at 12:36
404.php
has been found, index.php
is used.
if (is_404() && $template = get_404_template()):
there is a fantastic elseif
calling the get_search_template()
function, which will return you a 404 error, again, since it's not finding the string you are supposedly searching. And yes, I tried it.
Oct 8, 2015 at 12:52
elseif
matches only on search pages. This is never true
on a 404 page. Quite the opposite: a search without matches results in a 404.