As the title says, I would love to know if its possible to redirect to a WordPress page when an url is not found, but show a 404 response code on that page?
I've been playing around yesterday with header status 404 and location to a certain page in my 404.php, but this would always show a 200 response code.
I was wondering if I could do this without modifying the 404.php (only a redirect) and without a plugin.
Is there a tutorial or anything I can follow somewhere? I wasn't able to find this. Thanks in advance!
I tried all sorts of things:
<?php
header("Status: 404 Not Found");
header("Location: FULLURL / RELATIVEURL");
get_header(); ?>
But also these as response codes:
header("HTTP/1.0 404 Not Found");
http_response_code(404);
status_header(404);
I also tried placing the 404 under the redirect:
header("Location: FULLURL / RELATIVEURL");
header("Status: 404 Not Found");
- I also tried placing the 404 error codes on the page itself in a custom HTML block
- I even tried to iframe the page into the 404, but this wasn't the way to go either!