【问题标题】:How do I prevent google web crawler from reading a single page as two different pages如何防止谷歌网络爬虫将单个页面作为两个不同的页面读取
【发布时间】:2021-04-14 11:25:11
【问题描述】:

我有一个网页说 example.com/blog/news.php 我使用了这个代码:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]

.htaccess 文件中隐藏文件扩展名。但谷歌爬虫将 example.com/blog/news.phpexample.com/blog/news 读取为两个不同的页面。请问我该如何防止这种情况,我试图将 news.php 页面重定向到 news 但它返回了一条错误消息,说明重定向或类似的东西。

【问题讨论】:

    标签: html .htaccess seo


    【解决方案1】:

    您可以使用以下规则将您的 .php 网址 301 重定向到新的 (non-php ) 格式,这样 Google 只会将您的新网址编入索引。

    将以下内容放在RewriteEngine on 和现有规则之前:

    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^([^.]+)\.php$ /$1 [L,R=301]
    

    【讨论】:

      猜你喜欢
      • 2021-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-22
      • 2018-03-08
      • 1970-01-01
      • 2013-10-15
      相关资源
      最近更新 更多