我试图实现谷歌AJAX可抓取快照 。
为此,我在.htaccess
添加了以下重写条件,如下所示
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/?(.*)$ RewriteRule ^(.*)$ /snapshots/%1.html? [NC,L]
它工作正常,但在以下情况下失败。
www.mysite.com/#!/
这是爬行为www.mysite.com/?_escaped_fragment_=/
在谷歌文件。
我在我的快照目录中有一个准备好的index.html
来提供这样的请求
但是,对于上面的重写条件,它正在search.html
,结果403响应。 感谢您能够帮助我修复为index.html
页面提供这样的请求
上述用例需要额外的规则。 在现有规则上方插入此规则 :
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/$ [NC] RewriteRule ^ /snapshots/index.html? [NC,L] RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/?(.+)$ [NC] RewriteRule ^ /snapshots/%1.html? [NC,L]