Google 搜索优化笔记

网站迁移和变更

请将 https://1px.run/newurl 替换为自己的新链接,可以是完整的目录或者是带 https 或 http 协议的域名。

服务器重定向

服务器配置不同操作方式不同,如 Apache 在 .htaccess 文件配置

PHP 重定向

301 永久重定向

header('HTTP/1.1 301 Moved Permanently');
header('Location: https://1px.run/newurl');
exit();

302 临时重定向

header('HTTP/1.1 302 Found');
header('Location: https://1px.run/newurl');
exit();

meta refresh 及其 HTTP 等效项

即时 meta refresh 重定向:解析为永久重定向。

<meta http-equiv="refresh" content="0; url=https://1px.run/newurl">

延迟 meta refresh 重定向:解析为临时重定向。

<meta http-equiv="refresh" content="5; url=https://1px.run/newurl">

建议加上以下代码

<link rel="canonical" href="https://1px.run/newurl" />

JavaScript location 重定向

仅在无法实施服务器端重定向或 meta refresh 重定向时,才使用。但可能会由于各种原因而呈现失败。那么 Google 可能永远都无法看到该重定向。

<script>
  window.location.href = "https://1px.run/newurl";
</script>

rel= nofollow ugc sponsored 用法说明

  • nofollow 不表达任何类型的认可(不传递排名权重给这个链接)
  • ugc 用户生成的内容中的链接,可以和 nofollow 或 sponsored 组合使用
  • sponsored 广告、赞助或其他付费协议的链接
    • 广告链接 Google 更偏好这种,但是和 nofollow 的处理方式是一样的
    • 付费链接一定要带上,不然会受到处罚

rel= noopener noreferrer 用法说明

  • (本部分内容非谷歌提出)
  • noopener 阻止在当前窗口打开,和 target="_blank" 一起使用,防止打开页面获得对原始页面的任何访问权限。
  • noreferrer 没有推荐人,阻止浏览器传递来源信息,在谷歌分析可能就看不到来源,会被解析为直接来源

相关扩展阅读

  • rel=noreferrer 更好地保证用户浏览的隐私和安全 https://www.webkit.org/blog/907/webkit-nightlies-support-html5-noreferrer-link-relation/

回到顶部

Copyright © 2017-2024 1px.run (像素教程) Distributed by an MIT license.

Site updated at 2024-04-23 12:45