4

Our company's SEO expert asked me to set some particular pages to 410 - status gone.

I have searched about declaring 410 urls in .htaccess but I'm very confused, cause I don't understand if I have to redirect google bots to another url or just make a statement (just that these urls are missing, and don't search about them, they're gone). I'm also confused about how to do that, cause I've seen many differect codes reffering to 410, and I don't understand which one fits my case.

I think that the following code is what I need, but I'm not sure. Could you please check the following lines and tell me if they're correct? Do they set these urls to 410-status-gone?

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Redirect 410 /path_to_file/file1.html
Redirect 410 /path_to_file/file2.html
Redirect 410 /path_to_file/file3.html
</IfModule>
Cœur
  • 37,241
  • 25
  • 195
  • 267
zekia
  • 4,527
  • 6
  • 38
  • 47

2 Answers2

3

You can use:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^path_to_file/(file1|file2|file3)\.html$ - [L,NC,G]

</IfModule>

Flag G (Gone) is equivalent of R=410.

anubhava
  • 761,203
  • 64
  • 569
  • 643
  • I followed your instructions but SEO guy told me that files are still returning 404 error instead of 410. Any suggestions? – zekia Feb 27 '15 at 11:33
  • There is no 404 in my rule for above URLs. But there can be other code or rules not shown here or not covered by above regex. – anubhava Feb 27 '15 at 11:52
1

I wanted the same thing to do in my application. This is what I did in my .NET application.

Just add below 2 lines

HttpContext.Current.Response.StatusCode = System.Net.HttpStatusCode.Gone; HttpContext.Current.ApplicationInstance.CompleteRequest();

Cheers