How to return 410 for deleted web pages

Associate
Joined
25 Feb 2016
Posts
219
I changed my site to a wordpress site however some of my old pages keep showing in google search. I remove them in search console but they come back. My wordpress not found page returns a 301 and 404 code.

I've read I need to get them to return a 410.

I thought this would be something I could add to the html for each page so have added this:

<?php
header("HTTP/1.0 410 Gone");
exit;
?>
The requested page has been removed.

However checking an online tool the pages return code 200.

How can I get 5 old html pages to return a 410 code? I've read a bit about htaccess file but it's going over my head.
 
So like this:


# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Redirect gone /mypage.html
</IfModule>

# END WordPress

Edit:

Will it matter that the previous website was http but I have now updated to https?

I've saved those changes but I just get the normal wordpress not found page? Shouldn't it be a blank page?
 
Then why do pages keep coming back? I set a covid page and Google has added it to my buisness listing automatically. I've now deleted the page but it still shows in my business listing. I removed it in search console but after few days the removal expires and it's back. There is no option in business listing to delete it.
 
I get a wordpress not found page with a search box and a home page button. In chrome with f12 and looking at network tab shows 404. A site I found that shows the codes for urls gives 404 and 301.

I figured it was ok and after a temp removal (why can't you do permanent?) in Google search console that would be it, but some pages still show up in google search and the covid page reappears in my Google buisness listing.

I've recrawled the site hoping the missing urls would be forgotten but it doesn't work.

My site is built with elementor and oceanwp theme.
 
Back
Top Bottom