【问题标题】:Hash url (fragment) can be crawlable by search engines?哈希url(片段)可以被搜索引擎抓取吗?
【发布时间】:2015-10-10 12:44:21
【问题描述】:

我一直在研究 angularjs 和 php。

我有这个网址示例:

www.example.com/#/mysite

我正在尝试用谷歌搜索它,但我找不到它,为什么?

如果我搜索"mysite www.example.com",有没有办法在搜索引擎(google.com)中显示结果为"www.example.com/mysite",一旦我点击链接,它将被重定向到www.example.com/#/mysite

【问题讨论】:

    标签: php angularjs .htaccess url hash


    【解决方案1】:

    您正在 AngularJS 中寻找 HTML5 mode of the location provider。 Google 不会将在哈希后面路由的 URL 编入索引。这应该适用于 Angular 标准路由器和 ui-router。阅读有关 HTML5 模式的整篇文章,因为有很多需要注意的地方(包括 Google 抓取)。

    通过将$locationProvider.html5Mode(true) 添加到应用模块的config() 部分来启用它。

    主要需要注意的是,复制粘贴 URL 将不起作用,您必须配置服务器端以使所有路径都呈现 Angular 应用程序。 ui-router 有一些不错的documentation about this

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-13
      • 2012-10-09
      • 2020-10-03
      • 2011-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多