所以我正在开发一个网络应用程序,我想过滤搜索结果。
一个不错的 restful 实现可能是这样的:
1. mysite.com/clothes/men/hats+scarfs
但是假设我们想要像酷 child 一样加强过滤,并且我们想要保留深层链接,我们可能会使用 anchor 标记并使用 Javascript 解析它以显示正确的列表:
2. mysite.com/clothes#/men/hats+scarfs
但是,如果有人在启用 JS 的情况下点击第一个链接,然后更改过滤器,我们可能会得到:
3. mysite.com/clothes/men/hats+scarfs#/women/shoes
乌尔克。
同样,如果有人没有启用 JS,并单击链接 2 - JS 将不会解析选项,也不会显示正确的列表。
Ajax 深层链接和非 Ajax 链接是否不兼容?看起来是这样,因为服务器无法解析 url 的 # 部分,因为它没有发送到服务器。
最佳答案
Google 对这个问题提出了质疑: A proposal for making Ajax crawlable . Google 提供了有关 url 结构的建议,可能会为您提供有关您自己的应用程序的想法。
总结如下:
In summary, starting with a stateful URL such as
http://example.com/dictionary.html#AJAX
, it could be available to both crawlers and users ashttp://example.com/dictionary.html#!AJAX
which could be crawled ashttp://example.com/dictionary.html?_escaped_fragment_=AJAX
which in turn would be shown to users and accessed ashttp://example.com/dictionary.html#!AJAX
查看Google's Presentation here (注:谷歌文档介绍)
总的来说,我认为完全关闭 JavaScript 和 CSS 并浏览您的网站和 Web 应用程序并查看最终暴露的内容是有用的。一旦了解了可见的内容,您就会了解大多数搜索引擎看到的内容,这反过来会告诉您什么是被抓取的和没有被抓取的。
关于html - REST/Ajax 深度链接兼容性 - anchor 标记与查询字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1693290/