php seo 404 error in webmaster tool

0 votes

 I have a PHP site that has 1000s of pages, and I delete some pages every day that has been indexed by google.  If a visitor comes to one of the pages I have deleted, they will be taken to the "search for related contents " page.

The code I use : 
if($deleted = true){
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: /products-search.php");
    exit(); 
}

In the Google webmaster tool, I am getting a lot of soft 404 errors for the pages of this type. the message says: The target URL doesn't exist, but your server is not returning a 404 (file not found) error. Learn more

I don't want the user to get 404 error. Any solution ?

Mar 12, 2022 in Digital Marketing by Kichu
• 19,040 points
520 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

In your case, a redirect method is a bad idea to go with. You should return a 404 unless you expect to put that page back up later.
What you should do is anyways show the search page but return a 404 in the header.

<?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.

answered Mar 13, 2022 by narikkadan
• 63,600 points

edited Mar 5

Related Questions In Digital Marketing

0 votes
0 answers

SEO: Why "indexed pages" in Webmaster Tools and the command "site:" gives so much difference?

"Indexed URLs: 305,509"webmaser shows this when i ...READ MORE

Mar 2, 2022 in Digital Marketing by Kichu
• 19,040 points
557 views
0 votes
0 answers

.htaccess give 404 Not Found when url in SEO-friendly URL

Im using opencart fresh install and using ...READ MORE

Mar 4, 2022 in Digital Marketing by Kichu
• 19,040 points
1,240 views
0 votes
0 answers

Replace tags with space in PHP for SEO Meta Description

I am trying to strip tags from ...READ MORE

Mar 12, 2022 in Digital Marketing by Kichu
• 19,040 points
679 views
0 votes
0 answers

SEO and 404 error redirection

Recently I've removed some products and categories ...READ MORE

Mar 13, 2022 in Digital Marketing by Kichu
• 19,040 points
506 views
0 votes
0 answers

On installing seo suite in magento error is displayed

On installing mageworx SEO suite ultimate extension ...READ MORE

Mar 13, 2022 in Digital Marketing by Kichu
• 19,040 points
638 views
0 votes
0 answers

Replace tags with space in PHP for SEO Meta Description

I am trying to strip tags from ...READ MORE

Mar 13, 2022 in Digital Marketing by Kichu
• 19,040 points
743 views
+2 votes
2 answers

Is Reactjs SEO friendly? with google bots

Yes, with SERVER-SIDE RENDERING you will not face ...READ MORE

answered Feb 10, 2022 in Others by Shreesh
• 160 points
3,082 views
0 votes
1 answer

Google Indexing + Yoast SEO Media Attachments

as per the official yoast blog the ...READ MORE

answered Feb 11, 2022 in Others by narikkadan
• 63,600 points
589 views
0 votes
1 answer

Create an seo and web accessibility analyzer

there are some tools which  are already ...READ MORE

answered Feb 12, 2022 in Others by narikkadan
• 63,600 points
518 views
0 votes
1 answer

SEO - How to Show Phone Numbers in Google Search

<div itemscope itemtype="http://schema.org/LocalBusiness">         <span itemprop="telephone"><a href="tel:01234555666">Link Text Here</a></span>     </div> use ...READ MORE

answered Feb 14, 2022 in Others by narikkadan
• 63,600 points
495 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP