【发布时间】:2014-10-14 12:52:03
【问题描述】:
我遵循了这个教程: http://www.ng-newsletter.com/posts/serious-angular-seo.html
我正在使用修改过的 apache conf 从这里(原来没有工作,我改变了 HTTP_USER_AGENT 位) https://gist.github.com/thoop/8072354
现在我的 .htaccess 文件看起来像这样
# Change YOUR_TOKEN to your prerender token and uncomment that line if you want to cache urls and view crawl stats
# Change http://example.com (at the end of the last RewriteRule) to your website url
<IfModule mod_headers.c>
RequestHeader set X-Prerender-Token "MY TOKEN"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
Options +FollowSymLinks
#RewriteRule ^api/(.*)$ http://vivule.ee/api/$1 [P,L]
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/?(.*)$
RewriteRule ^(.*)$ /snapshots/%1? [NC,L]
# Prerender.io stuff
<IfModule mod_proxy_http.c>
RewriteCond %{HTTP_USER_AGENT} Googlebot|bingbot|Googlebot-Mobile|Baiduspider|Yahoo|YahooSeeker|DoCoMo|Twitterbot|TweetmemeBot|Twikle|Netseer|Daumoa|SeznamBot|Ezooms|MSNBot|Exabot|MJ12bot|sogou\sspider|YandexBot|bitlybot|ia_archiver|proximic|spbot|ChangeDetection|NaverBot|MetaJobBot|magpie-crawler|Genieo\sWeb\sfilter|Qualidator.com\sBot|Woko|Vagabondo|360Spider|ExB\sLanguage\sCrawler|AddThis.com|aiHitBot|Spinn3r|BingPreview|GrapeshotCrawler|CareerBot|ZumBot|ShopWiki|bixocrawler|uMBot|sistrix|linkdexbot|AhrefsBot|archive.org_bot|SeoCheckBot|TurnitinBot|VoilaBot|SearchmetricsBot|Butterfly|Yahoo!|Plukkie|yacybot|trendictionbot|UASlinkChecker|Blekkobot|Wotbox|YioopBot|meanpathbot|TinEye|LuminateBot|FyberSpider|Infohelfer|linkdex.com|Curious\sGeorge|Fetch-Guess|ichiro|MojeekBot|SBSearch|WebThumbnail|socialbm_bot|SemrushBot|Vedma|alexa\ssite\saudit|SEOkicks-Robot|Browsershots|BLEXBot|woriobot|AMZNKAssocBot|Speedy|oBot|HostTracker|OpenWebSpider|WBSearchBot|FacebookExternalHit [NC,OR]
RewriteCond %{QUERY_STRING} _escaped_fragment_
# Only proxy the request to Prerender if it's a request for HTML
RewriteRule ^(?!.*?(\.js|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.gif|\.pdf|\.doc|\.txt|\.ico|\.rss|\.zip|\.mp3|\.rar|\.exe|\.wmv|\.doc|\.avi|\.ppt|\.mpg|\.mpeg|\.tif|\.wav|\.mov|\.psd|\.ai|\.xls|\.mp4|\.m4a|\.swf|\.dat|\.dmg|\.iso|\.flv|\.m4v|\.torrent))(.*) http://service.prerender.io/http://vivule.ee/$2 [P,L]
</IfModule>
</IfModule>
但是,如果我像prerender.io 上推荐的那样使用转义片段进行测试,似乎什么也没有发生。你可以自己查:http://vivule.ee/?_escaped_fragment_=或http://vivule.ee/0/?_escaped_fragment_=
如果我尝试使用 facebook 分享功能,它仍然会得到没有被 angular 脚本修改的 html。 (试过这个工具:https://developers.facebook.com/tools/debug/og/object/获取最新数据,但无济于事。
任何想法如何测试预渲染是否正常工作?
【问题讨论】:
-
你能检查一下你是否启用了 mod_rewrite.c 和 mod_proxy_http.c 吗?此外,您应该删除您的 Prerender.io 令牌并通过我们的 UI 生成一个新令牌,这样任何人都无法使用您的令牌来缓存您帐户下的页面。
-
@Prerender.io 感谢您的建议,一些优秀的管理员已经删除了令牌。到主题 - mod_rewrite.c 和 mod_proxy_http.c 都已启用。 PS!哇,没想到会直接听到开发人员的消息:D
-
@Prerender.io Google Webmaster Tools 是否应该呈现缓存版本?
标签: javascript angularjs .htaccess seo prerender