gabriele Balli
gabriele Balli

Reputation: 15

Set header 410 to parameter can remove index from serp?

i need to set a 410 for pages that contains parameter stats with "?apple". I try this code :<?php if (strpos($_SERVER['REQUEST_URI'], '?apple') !== false) { header("HTTP/1.0 410 Gone"); exit; } ?> i have some page link like : webiste.com/?apple , website.com/?apple-fruit IF i use this code, the homepage will remove from Google ?

Remove only the page with parameters, not the root.

Upvotes: 0

Views: 107

Answers (1)

mikulabc
mikulabc

Reputation: 126

If this is only a temporary problem

You can remove the URLs directly in Google Search Console by following the steps here: https://search.google.com/search-console/removals?resource_id=sc-domain%3Awebsite.com (replace "website.com" with your actual website)

You need to have the website registered in GSC for this to work.

If you don't have access to GSC

I advise you to use canonical URLs instead, this is common practice to make sure Google does not index canonical URLs such as "/?apple" parameters.

The simple fix for this would be to include this simple line in the of each page pointing to itself:

eg. https://website.com/ gets:

<link rel="canonical" href="https://website.com/" />

and https://website.com/another-page/ gets:

<link rel="canonical" href="https://website.com/another-page/" />

this will prevent Google from putting the parameter URLs in the index.

Upvotes: 0

Related Questions