最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to check if prerender.io is working correctly on my angularjs site? - Stack Overflow

programmeradmin1浏览0评论

I followed this tutorial: .html

And I'm using modified apache conf from here (original didn't work, I changed the HTTP_USER_AGENT bit)

Right now my .htaccess file looks like this

    # Change YOUR_TOKEN to your prerender token and unment that line if you want to cache urls and view crawl stats
    # Change  (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/(.*)$ /$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\sBot|Woko|Vagabondo|360Spider|ExB\sLanguage\sCrawler|AddThis|aiHitBot|Spinn3r|BingPreview|GrapeshotCrawler|CareerBot|ZumBot|ShopWiki|bixocrawler|uMBot|sistrix|linkdexbot|AhrefsBot|archive_bot|SeoCheckBot|TurnitinBot|VoilaBot|SearchmetricsBot|Butterfly|Yahoo!|Plukkie|yacybot|trendictionbot|UASlinkChecker|Blekkobot|Wotbox|YioopBot|meanpathbot|TinEye|LuminateBot|FyberSpider|Infohelfer|linkdex|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))(.*) ://vivule.ee/$2 [P,L]
        </IfModule>

    </IfModule>

But if I test with escaped fragment like it's remended on prerender.io, nothing seems to happen. You can check yourself: /?_escaped_fragment_= or /?_escaped_fragment_=

And if I try out the facebook sharing function, it still get's the html which is not modified by the angular script. (Tried this tool: / to get the latest data, but to no avail).

Any ideas how to test if the prerender is even working?

I followed this tutorial: http://www.ng-newsletter./posts/serious-angular-seo.html

And I'm using modified apache conf from here (original didn't work, I changed the HTTP_USER_AGENT bit) https://gist.github./thoop/8072354

Right now my .htaccess file looks like this

    # Change YOUR_TOKEN to your prerender token and unment that line if you want to cache urls and view crawl stats
    # Change http://example. (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.\sBot|Woko|Vagabondo|360Spider|ExB\sLanguage\sCrawler|AddThis.|aiHitBot|Spinn3r|BingPreview|GrapeshotCrawler|CareerBot|ZumBot|ShopWiki|bixocrawler|uMBot|sistrix|linkdexbot|AhrefsBot|archive_bot|SeoCheckBot|TurnitinBot|VoilaBot|SearchmetricsBot|Butterfly|Yahoo!|Plukkie|yacybot|trendictionbot|UASlinkChecker|Blekkobot|Wotbox|YioopBot|meanpathbot|TinEye|LuminateBot|FyberSpider|Infohelfer|linkdex.|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>

But if I test with escaped fragment like it's remended on prerender.io, nothing seems to happen. You can check yourself: http://vivule.ee/?_escaped_fragment_= or http://vivule.ee/0/?_escaped_fragment_=

And if I try out the facebook sharing function, it still get's the html which is not modified by the angular script. (Tried this tool: https://developers.facebook./tools/debug/og/object/ to get the latest data, but to no avail).

Any ideas how to test if the prerender is even working?

Share Improve this question edited Aug 22, 2014 at 3:11 CommunityBot 11 silver badge asked Aug 21, 2014 at 1:32 yodalryodalr 10.9k10 gold badges36 silver badges50 bronze badges 3
  • 1 Can you check if you have mod_rewrite.c and mod_proxy_http.c enabled? Also, you should remove your Prerender.io token and generate a new one through our UI so that no one can use your token to cache pages under your account. – Prerender.io Commented Aug 21, 2014 at 16:14
  • @Prerender.io thanks for the suggestion, some good admin already removed the token. To the topic - both mod_rewrite.c and mod_proxy_http.c are enabled. PS! Wow, didn't expect to hear straight from the dev :D – yodalr Commented Aug 22, 2014 at 8:50
  • @Prerender.io should Google Webmaster Tools be rendering the cached version or no? – irth Commented Oct 16, 2014 at 22:20
Add a ment  | 

1 Answer 1

Reset to default 8

Ok, I fixed it, seems like all I had to do is move the "RewriteRule ^ index.html [L]" to the end of the .htaccess file. .htaccess file is read from top to bottom, and I guess it never go to the prerender part before.

Here's the .htaccess code that works: # Change YOUR_TOKEN to your prerender token and unment that line if you want to cache urls and view crawl stats # Change http://example. (at the end of the last RewriteRule) to your website url

        <IfModule mod_headers.c>
            RequestHeader set X-Prerender-Token "MY SECRET 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]


            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.\sBot|Woko|Vagabondo|360Spider|ExB\sLanguage\sCrawler|AddThis.|aiHitBot|Spinn3r|BingPreview|GrapeshotCrawler|CareerBot|ZumBot|ShopWiki|bixocrawler|uMBot|sistrix|linkdexbot|AhrefsBot|archive_bot|SeoCheckBot|TurnitinBot|VoilaBot|SearchmetricsBot|Butterfly|Yahoo!|Plukkie|yacybot|trendictionbot|UASlinkChecker|Blekkobot|Wotbox|YioopBot|meanpathbot|TinEye|LuminateBot|FyberSpider|Infohelfer|linkdex.|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>

            # Rewrite everything else to index.html to allow html5 state links
            RewriteRule ^ index.html [L]

        </IfModule>
发布评论

评论列表(0)

  1. 暂无评论
ok 不同模板 switch ($forum['model']) { /*case '0': include _include(APP_PATH . 'view/htm/read.htm'); break;*/ default: include _include(theme_load('read', $fid)); break; } } break; case '10': // 主题外链 / thread external link http_location(htmlspecialchars_decode(trim($thread['description']))); break; case '11': // 单页 / single page $attachlist = array(); $imagelist = array(); $thread['filelist'] = array(); $threadlist = NULL; $thread['files'] > 0 and list($attachlist, $imagelist, $thread['filelist']) = well_attach_find_by_tid($tid); $data = data_read_cache($tid); empty($data) and message(-1, lang('data_malformation')); $tidlist = $forum['threads'] ? page_find_by_fid($fid, $page, $pagesize) : NULL; if ($tidlist) { $tidarr = arrlist_values($tidlist, 'tid'); $threadlist = well_thread_find($tidarr, $pagesize); // 按之前tidlist排序 $threadlist = array2_sort_key($threadlist, $tidlist, 'tid'); } $allowpost = forum_access_user($fid, $gid, 'allowpost'); $allowupdate = forum_access_mod($fid, $gid, 'allowupdate'); $allowdelete = forum_access_mod($fid, $gid, 'allowdelete'); $access = array('allowpost' => $allowpost, 'allowupdate' => $allowupdate, 'allowdelete' => $allowdelete); $header['title'] = $thread['subject']; $header['mobile_link'] = $thread['url']; $header['keywords'] = $thread['keyword'] ? $thread['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>