I have a PHP site wich contains 1000s of pages ... Every day i delete 10s of pages which already indexed by GOOGLE....
When visitor come to one of thos pages i do check to see if it is deleted or not ... If deleted i redirect the user to the search page to start search for similar contents ... I am using this code :
if($deleted = true){
header("HTTP/1.1 301 Moved Permanently");
header("Location: /products-search.php");
exit();
}
the problem that in GOOGLE webmaster tool i get alot of soft 404 errors for the pages of this type. the message say : The target URL doesn't exist, but your server is not returning a 404 (file not found) error. Learn more
i dont want the user to get 404 error .... i need him to go to search page ...
How to solve this ?
You should still return a 404 unless you expect to put that page back up later. A redirect is a bad idea for SEO in this case.
What you could do is return a 404 in the header but show the search page anyway:
<?php
header("HTTP/1.1 404 Not Found");
echo "The page you're looking for doesn't exist or was deleted. You can use the search below to find more...";
// include search box here