If I user goes to a page that doesn’t exist I want to send him to a 404.html that is outside the wordpress folder (I have multiple wordpress sites as subfolders in the root of a domain, and want them all to be sent to the same 404 which is in the root folder).
Found this, which I tried to add to 404.php in my theme directory:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location:http://www.exmaple.com/");
?>
The reason why PHP redirection doesn’t work is, that because this part of code should be set on beggining of document, just before <!doctype>.Maybe you can do something like this:
Go into header.php, at the beggining of file add this:
<?php
if ( is_404() ) {
header("HTTP/1.1 301 Moved Permanently");
header("Location:http://www.exmaple.com/");
}
?>