【问题标题】:Google crawled my dynamic urls instead of static urlsGoogle 抓取了我的动态网址而不是静态网址
【发布时间】:2021-09-21 22:07:05
【问题描述】:

我使用 .htaccess 文件将动态网址转换为静态网址。

例如:doctor.php?id=1 to doctor/firstname-lastname-1

htaccess (RewriteRule ^doctor/([^/]+)/? doctor.php?id=$1 [L])

注意:名字和姓氏只是关键字,我使用最后一个 url 元素作为 ID 来获取页面结果。

我已将站点地图添加到谷歌。站点地图和网站上的所有 url 都是静态的,但是当我在 google 上看到结果时我感到震惊。 url 是动态的(例如:doctor.php?id=1)而不是静态的。谷歌应该抓取站点地图和网页上的静态网址!!

我希望这些网址像这样出现在谷歌上:doctor/firstname-lastname-1

【问题讨论】:

  • 欢迎来到 SO,感谢您在问题中添加您的努力。关于你的声明I have added sitemaps to google. all urls on sitemaps and on the website are static, but I shocked when I saw the result on google. urls are dynamic(ex:doctor.php?id=1) instead of static. how can I solve this issue.你能否详细说明这一点。
  • 对不起兄弟,我是新来的,我真的需要帮助,我网站上的网址都是静态的,但它们在谷歌引擎上显示为动态网址。
  • 某事、某处和/或某时踢出谷歌发现的那些动态 URL。也许有一个规范的链接标签或标题?至于您的 htaccess,您现在可能需要为这些旧网址添加 301 重定向,并且随着时间的推移,Google 会更正您的首选模式。
  • 设置元标记Canonical 告诉谷歌原始页面是什么
  • 使用 301 重定向将您的动态网址重定向到静态网址并重新提交站点地图

标签: php laravel .htaccess


【解决方案1】:

您可以使用以下 htaccess 代码将您的动态 URL 301 重定向到静态。

RewriteEngine on

RewriteCond %{THE_REQUEST} doctor\.php\?id=([^\s]+) [NC]
RewriteRule ^ /doctor/%1? [L,R=301]
RewriteRule ^doctor/([^/]+)/? doctor.php?id=$1 [L]

【讨论】:

    猜你喜欢
    • 2013-11-29
    • 1970-01-01
    • 1970-01-01
    • 2013-07-25
    • 2021-08-08
    • 2012-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多