用版本以hash bang结尾的deindex a URL

发布于 2025-01-28 17:54:12 字数 195 浏览 4 评论 0原文

我只想删除或删除以#!结尾的页面。 这是一个动态页面,从数据库获取数据并在两个URL上渲染

  • example.com/detail/297#!
  • example> example> example> example.com/detail/297

I just want to deindex or remove the page ending with #!.
It is a dynamic page which fetching data from database and rendering on two URLs

  • example.com/detail/297#!
  • example.com/detail/297

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾城花音 2025-02-04 17:54:12

如果您想删除这两个URL,则应为其返回“ 410 GONE” http状态。 (或者甚至“未找到”状态的“ 404”状态将起作用,但它并不那么描述。)

如果您只想删除Hash Bang的版本,那就很难了。带有哈希的URL,共享相同的HTTP请求,响应和状态代码与没有哈希的版本。这意味着只能使用JavaScript来处理URL的哈希部分。您将需要将JavaScript插入到页面中,以检测到Hash Bang的存在并实现以下内容:

  • 更改location.href以删除Hash Bang
  • 更改location.href < /code>到“ 410 got”错误页面的URL,
  • 动态插入a &lt; meta name =“ robots” content =“ noindex”&gt; tag tag中/代码>页面的。

If you want to deindex both of those URLs you should return a "410 Gone" HTTP status for them. (Or even a "404 Not Found" status would work but it isn't as descriptive.)

If you want to deindex only the version with the hash bang, that is a little harder. URLs with the hash, share the same HTTP request, response, and status code as the version without the hash. That means that handling the hash portion of the URL can only be done with JavaScript. You will need to insert JavaScript into the page that detects that presence of the hash bang and implements one of the following:

  • Changes the location.href to remove the hash bang
  • Changes the location.href to the URL of a "410 Gone" error page
  • Dynamically inserts a <meta name="robots" content="noindex"> tag into the <head> of the page.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文