Redirect 404.php to URL outside the site?

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/");
	?>

But that doesn’t do anything.

Anyone that can help me with this?

You can use easy redirect wordpress plugin… it will help you to do it in just few clicks.

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/");
    } 
 ?>

EDIT: Sorry on wrong reply.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.