3

我们公司的 SEO 专家要求我将某些特定页面设置为 410 - 状态已消失。

我已经搜索过在 .htaccess 中声明 410 个 url 但我很困惑,因为我不明白我是否必须将 google bot 重定向到另一个 url 或只是发表声明(只是这些 url 丢失了,不要搜索他们,他们走了)。我也对如何做到这一点感到困惑,因为我看到许多不同的代码引用 410,我不明白哪一个适合我的情况。

我认为以下代码是我需要的,但我不确定。您能否检查以下几行并告诉我它们是否正确?他们是否将这些网址设置为 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>
4

2 回答 2

3

您可以使用:

<IfModule mod_rewrite.c>
RewriteEngine On

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

</IfModule>

标志G(Gone) 等价于R=410.

于 2015-02-25T11:02:56.773 回答
1

我想在我的应用程序中做同样的事情。这就是我在 .NET 应用程序中所做的。

只需添加以下 2 行

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

干杯

于 2018-08-31T11:28:36.280 回答