为什么 prerender.io 不能在我的 apache 共享服务器上使用 angularjs 工作?



我是一名Linux新手,正在努力确保我的angular/bootstrap应用程序的SEO排名。我曾尝试在共享GoDaddy服务器上的几个文件夹中的.htaccess文件中应用prerender.io中间件,但没有成功。我已经联系了该产品的所有者Todd,但他一直无法提供可行的解决方案。他似乎有点不知所措。

我错过了什么?.htaccess应位于何处?这是我想预先呈现的网站。

public_html:前面文件夹中的我的.htaccess文件

更新(最新完整.htaccess)

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
<IfModule mod_setenvif.c>
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
</IfModule>
<IfModule mod_headers.c>
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>
RewriteCond %{SERVER_PORT} 80      
# 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
<IfModule mod_proxy_http.c>
RewriteCond %{HTTP_USER_AGENT} baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator [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|.ttf|.woff))(index.html.var)(.*) http://service.prerender.io/http://writers-tryst.ron-tornambe.com/$3 [P,L] </IfModule>
</IfModule>

编辑

我修改了导航栏列表如下:

<ul class="nav navbar-nav">
<li class="active"><a id="homepage" href="?_escaped_fragment_=/"><i class="glyphicon glyphicon-home"></i> Home</a></li>
<li><a href="?_escaped_fragment_=/writers/" class="glyphicon glyphicon-book"> Writers</a></li> 

角度"何时"看起来像这样:

wtApp.config(function ($routeProvider) {
$routeProvider
// route for the home page
.when('/', {
templateUrl: 'pages/home.html',
controller: 'mainController'
})
// route for the writers page
.when('/writers', {
templateUrl: 'pages/writers.html',
controller: 'writersController'
})

URL如下所示:

http://writers-tryst-test.ron-tornambe.com/?_escaped_fragment_=/writers#/

写入程序页面不会显示。它仍然在主页上。

我不知道为什么要添加#。如果我把它取下来,它就会重新插入。

我会不断调整的——我知道我已经接近了。

您需要重新生成Prerender.io令牌,因为您在配置中公开了它。其他人可能会用你的代币给你一大笔钱。转到我们网站的帐户部分,您将在那里看到重新生成代币的选项。

此外,即使regex中有3个捕获组,您仍然有$2。第三个捕获组是您想要发送到我们服务的内容。

你试过我上次发给你的配置了吗?

# 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 "YOUR_TOKEN"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
<IfModule mod_proxy_http.c>
RewriteCond %{HTTP_USER_AGENT} baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator [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|.ttf|.woff))(index.html.var)(.*) http://service.prerender.io/http:/%{HTTP_HOST}/$3 [P,L] </IfModule>
</IfModule>

如果可行,请告诉我。很乐意帮忙!

最新更新