对于AJAX抓取阿帕奇重写条件 [英] Apache rewrite condition for ajax crawling
问题描述
我想实现谷歌AJAX抓取快照的。
有关这个我已经添加按照的.htaccess
如下重写条件
For this I've added following rewrite conditions in .htaccess
as follows
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/?(.*)$
RewriteRule ^(.*)$ /snapshots/%1.html? [NC,L]
它工作正常,但在下列情况下失败。
It works fine but it fails in following situation.
www.mysite.com/#!/
这是因为爬 www.mysite.com /?_ escaped_fragment _ = /
作为谷歌文档。
This is crawled as www.mysite.com/?_escaped_fragment_=/
as in the google documents.
我有一个ppared $ P $ index.html的
在我的快照目录服务这样的请求。
I have a prepared index.html
in my snapshots directory to serve such requests
但对于上述重写条件正在搜索的.html
,并导致403响应。鸭preciate如果你能帮助我解决服务 index.html的
这样的请求页
But for the above rewrite condition it is searching for .html
and that results 403 response. Appreciate if you can help me to fix to serve index.html
page for such requests
推荐答案
您将需要上述使用案例的附加规则。将这一规则的您现有的规则上面
You will need an additional rule for above use case. Insert this rule above your existing rule:
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/$ [NC]
RewriteRule ^ /snapshots/index.html? [NC,L]
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/?(.+)$ [NC]
RewriteRule ^ /snapshots/%1.html? [NC,L]
这篇关于对于AJAX抓取阿帕奇重写条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!