Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ajax 搜索引擎优化的CouchDB URL重写_Ajax_Seo_Couchdb_Hashbang - Fatal编程技术网

Ajax 搜索引擎优化的CouchDB URL重写

Ajax 搜索引擎优化的CouchDB URL重写,ajax,seo,couchdb,hashbang,Ajax,Seo,Couchdb,Hashbang,我正在尝试使用大量客户端Jquery/AJAX魔术创建一个完全托管在CouchDB(也没有nginx反向代理)上的整个站点。现在,我正在使它的搜索引擎优化友好的过程。我正在使用vhost和URL重写将流量从根目录路由到index.html文件: vhost: example.com/dbname/\u design/dd/\u rewrite/ 在我的重写定义中: rewrites:[ { "from": "/db/*", "to": "/../../../*"

我正在尝试使用大量客户端Jquery/AJAX魔术创建一个完全托管在CouchDB(也没有nginx反向代理)上的整个站点。现在,我正在使它的搜索引擎优化友好的过程。我正在使用vhost和URL重写将流量从根目录路由到index.html文件:

vhost:

example.com/dbname/\u design/dd/\u rewrite/

在我的重写定义中:

rewrites:[
   {
       "from": "/db/*",
       "to": "/../../../*",
       "query": {
       }
   },
   {
       "from": "/",
       "to": "../../static/index.html",
       "query": {
       }
   }
]
:

  • 在您友好的URL中使用hashbang(#!)告诉网络爬虫您是一个具有网络可爬虫材料的AJAX站点:
    http://example.com/index.html#!主页
  • 使用http查询参数提供该AJAX页面的HTML转义片段:
    http://example.com/index.html?_escaped_fragment=home
我尝试了以下方法,但没有成功:

rewrites:[
   {
       "from": "/db/*",
       "to": "/../../../*",
       "query": {
       }
   },
   {
       "from": "/",
       "to": "../../static/index.html",
       "query": {
       }
   }, /* FIRST ATTEMPT */
      {
       "from": "/?_escaped_fragment=:_escaped_fragment",
       "to": "/_show/escaped_fragment/:_escaped_fragment",
       "query": {
       }
   }, /* SECOND ATTEMPT */
      {
       "from": "/?_escaped_fragment=*",
       "to": "/_show/escaped_fragment/*",
       "query": {
       }
   }, /* THIRD ATTEMPT */
      {
       "from": "/",
       "to": "/_show/escaped_fragment/:_escaped_fragment",
       "query": {
       }
   }
]

从我所看到的,CouchDB的URL重写器无法区分带有args和无args的URL之间的区别。有人有幸用CouchDB URL重写创建了这样一个规则吗?

我对这个问题没有答案,但我已经为在CouchDB上创建可爬行网站这一更大的问题开发了一个解决方案。它是一个系统,使用、列出和显示功能、客户端上的ajax和
窗口历史
在CouchDB和浏览器上呈现相同的HTML组件,其中包含数据:


此解决方案不需要hashbang,因为对于浏览器导航到的每个唯一URL,使用ajax和
window.history
或简单链接(可以是
\u list/listName/viewName
/
\u show/displayKind/c305ee4d-8611-4e08-b9d3-3318835632a9
或重写为
/name
/kind/c305ee4d-8611-4e08-b9d3-3318835632a9),服务器可以呈现相关内容。

您的第三次尝试是唯一正确的。只需查询
/\u design/ddoc/\u rewrite?\u escaped\u fragment=foo
,它将被重写为
/\u design/ddoc/\u show/escaped\u fragment/foo
。当然,您需要在这种情况下定义
escaped\u fragment
show函数。@Kxepal是唯一的pr第三个选项的问题是CouchDB将其视为与我的重写规则相同,用于将“/”发送到“../../static/index.html”。是的,冲突。可能会合并它们吗?在这种情况下,
:\u转义片段
将是
未定义的
\u rewrite/
->
\u show/escape\u fragment/undefined
),但您会注意到,查询对象中缺少了他,所以应该可以很容易地从show函数重定向到
static/index.html
(不好,但仍然是解决方案)我曾考虑过使用重定向,但谷歌的规范说,它必须是完全相同的URL,网站才能进行爬网:
http://example.com/index.html#!主页
&
http://example.com/index.html?_escaped_fragment=home
。如果我重定向到与
http://example.com/index.html
,我会的以一个新的URL结束(追逐我的尾巴)顺便说一句,我可能找不到这个问题的解决方案,但我找到了一个潜在的SEO hashbang/escape_fragment方法的替代方法:感谢这个解决方案。我已经使用纯客户端Javascript开发了一个类似的方法。我在我的个人博客上使用它:基本上,我在浏览器中呈现页面,然后捕获整个文档初始化、序列化并将其另存为附件。当用户/爬虫直接浏览到链接时,会返回此附件。否则,我将使用HTML5历史api加载/卸载AJAX页面。