有时候,我们在百度搜索某关键词会发现,百度结果页出现的信息,和我们点击进去之后所看到的信息完全不一样,这个是某些为了做seo特意做出来的,下面介绍其中一个方法。

如果使用nginx的话,只需要在nginx中插入下面伪静态的写法,就可以达到这个目的:

if ($http_user_agent ~* "Googlebot|Yahoo!")
{
  rewrite "^/(.*)$" https://www.baidu.com/ break;
}
if (!-f $request_filename) {
  rewrite /index.html /index.php;
  rewrite /admin/$ /admin/index.php;
  rewrite /cloud/$ /cloud/index.php;
  rewrite ^/sitemap(.*).xml /xml.php;
  rewrite ^/sitemap(.*).html /sitemap.php;
  rewrite ^/robots.txt /robots.php;
  rewrite ^/(.*).html /article.php;
  rewrite ^/(.*)/$ /article.php;
}

Googlebot,Yahoo!就是谷歌和雅虎的蜘蛛名称,第一个if中就是将谷歌和雅虎的蜘蛛直接跳转(或者叫做引导)到百度(https://www.baidu.com/)首页去,这样就会出现谷歌或者雅虎如果收录了这个页面,其实页头tille和keyword包括介绍,都是百度的。第二个if就是你网站程序的伪静态写法,不冲突。

以上算是半黑科技,一般人不用,也建议慎用。

Chinese Stock News 7x24
Last modification:August 25, 2019
如果觉得我的文章对你有用,请随意赞赏