1

I have some content to be permanently deleted from my website. This is a permanent deletion and I am planning to give 410 status code.

I can very well return the status code in PHP page as

header( "HTTP/1.1 410 Gone" );
exit

or using rewrite rule in .htacccess as

RewriteRule ^deleted/ - [L,R=410]

I am clear till this point. However, I would like to redirect users to another page to explain why some pages are no more available.

So, is a redirect to another page with 410 code fine? I am specifically asking this, because I feel it is confusing to redirect to such a page (where search engine may take it as a redirect), but then giving 410 code at the same time.

What is the right approach for this. please help.

2

So, is a redirect to another page with 410 code fine?

A redirect is not necessary. Define a custom 410 error document:

ErrorDocument 410 /error-docs/e410.php

And trigger the 410 in .htaccess, as you did before:

RewriteRule ^deleted/ - [G]

The G flag is simply a shortcut for R=410 and the L flag is not required (it is implied when using a status code other than 3xx).

The error document /error-docs/e410.php is called using an internal subrequest (no external redirect).

In e410.php you can examine the URL that triggered the 410 (ie. $_SERVER['REDIRECT_URL']) if you wish to deliver a specific message for different URLs.

I am specifically asking this, because I feel it is confusing to redirect to such a page (where search engine may take it as a redirect), but then giving 410 code at the same time.

Yes, it is confusing and inefficient. Although search engines will ultimately see the 410 Gone status - so it should still "work" indirectly. But this is inefficient (2 requests/responses) - a 3xx followed by a 410 (in the 2nd - redirected - response). If you "redirect" to your error document then you can't examine details of the initial request that triggered the 410 in the first place.

Reference:

  • 1
    this is very clear answer and things look simpler now. I was totally confused and you saved my day. thanks – Kiran Jan 19 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.