.htaccess - 410 状态代码所需的 mod_rewrite 帮助

标签 .htaccess mod-rewrite seo http-status-code-410

如果 URL 上有 ?,我想发送 410 状态码。因为该站点仅适用于启用 SEO 的 URL(如 www.domain.com/seo-enabled-urls)。

在 StatckOverflow 社区的支持下,这个 301 重定向非常有效:

RewriteBase /
RewriteRule ^romance-package-two\.html$ http://www.domain.com/wedding-champagne [QSA,NC,R=301,L]

以同样的方式,我想添加 410 消息代码,告诉 Google(如搜索引擎)永久删除,这样我们就不会遇到 SEO 未知或找不到 URL 的问题。

如果 URL 看起来像这样

www.domain.com/seo-enabled-urls?param1=val1&param2=val2

我想保留相同的 URL,但只使用像这样的 410 代码

RewriteCond %{query_string} ^(.*&)?$ [NC]
RewriteRule ^1$  same url code [QSA,NC,R=410,L]

请帮帮我。

最佳答案

您不能使用 HTTP 410 代码重定向 -- 410 意味着请求的页面已永久消失,并且没有替代品:

410 Gone

The requested resource is no longer available at the server and no forwarding address is known. This condition is expected to be considered permanent. Clients with link editing capabilities SHOULD delete references to the Request-URI after user approval. If the server does not know, or has no facility to determine, whether or not the condition is permanent, the status code 404 (Not Found) SHOULD be used instead. This response is cacheable unless indicated otherwise.

-- http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.11


HTTP 301对应的定义说明已经是你想要的了:

301 Moved Permanently

The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible. This response is cacheable unless indicated otherwise.

-- http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2

关于.htaccess - 410 状态代码所需的 mod_rewrite 帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7129376/

相关文章:

jQueryMobile 的数据标题未显示在搜索结果中

seo - 谷歌站长工具 : Sitemaps not indexing?

php - 此 mod_rewrite 规则如何导致我的任何文件无法加载?

node.js - Next.JS - `.htaccess` 文件?

linux - 将域指向托管服务器文件夹时出现问题

java - 将此 Apache Rewrite 规则转换为 tuckey URLRewriteRule

php - mod_rewrite 问题和 php

svn - 为什么 Subversion 不允许提交 .htaccess 文件?

xml - 一个 typo3 实例中用于多域的 Typo3 多个站点地图

jquery - AJAX + SEO 快速提问