PhantomJS does not support valid JS and CSS files

I have a node server that is running and listening on port 8080. There is a mod_rewrite rule that redirects bots to this port.

RewriteCond %{HTTP_USER_AGENT} (googlebot|adsbot-google|bingbot|msnbot|psbot|gigabot|twitterbot|linkedinbot|yahoo-mmcrawler|pingdom\.com_bot) [NC]
RewriteRule ^ http://127.0.0.1:8080%{REQUEST_URI} [P]

The node script relies on a phantomjs script to open any bot request urls and return the contents.

Code taken here http://backbonetutorials.com/seo-for-single-page-apps/

I tested this by running phantomjs on my local machine and requesting my webpage directly with the same phantomjs code. The results are similar to those indicated by "Google crawl" (Google’s webmaster tools), namely that the CSS and JS files are not properly served by phantomjs.

CSS file contains only

<html><head></head><body></body></html>

and no actual CSS content. There is a JS file

<html><head></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">

inserted at the very beginning before any JS code.

, Google , , JS .

? .

+4
1

. .

probally page.content. html. :

    if (url.indexOf('.html') > -1) cb(page.content);
    else cb(page.plainText);

htaccess.

RewriteCond %{HTTP_USER_AGENT} (googlebot|adsbot-google|bingbot|msnbot|psbot|gigabot|twitterbot|linkedinbot|yahoo-mmcrawler|pingdom\.com_bot) [NC]
RewriteCond %{REQUEST_URI} (.*).html(.*) <---- ADDED THIS ONE
RewriteRule ^ http://%{HTTP_HOST}:3004%{REQUEST_URI} [P]
+2

All Articles