经过大量时间的努力,试图让我的网站SEO友好而不渲染它,似乎是不可能与AngularJS。现在我正在尝试使用prerender io,但我没有完全得到配置。我注册了prerender io,我得到了我的令牌,我制作了我的htacess文件,但我仍然收到消息您需要安装Prerender令牌才能开始缓存您的页面。
我的htacess文件来自官方preredner io github上的recomendation
htacess
RewriteEngine On
# If requested resource exists as a file or directory
# (REQUEST_FILENAME is only relative in virtualhost context, so not usable)
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
# Go to it as is
RewriteRule ^ - [L]
# If non existent
# If path ends with / and is not just a single /, redirect to without the trailing /
RewriteCond %{REQUEST_URI} ^.*/$
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^(.*)/$ $1 [R,QSA,L]
# Handle Prerender.io
RequestHeader set X-Prerender-Token "mytoken"
RewriteCond %{HTTP_USER_AGENT} baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest [NC,OR]
RewriteCond %{QUERY_STRING} _escaped_fragment_
# Proxy the request
RewriteRule ^(.*)$ http://service.prerender.io/http://%{HTTP_HOST}$1 [P,L]
# If non existent
# Accept everything on index.html
RewriteRule ^ /index.html#!
我在html5模式下工作,但是有了hashbang回退,它运行得很好。
MAIN.JS
app.config(['$ routeProvider','$ locationProvider',function($ routes,$ location){ $ location.html5Mode(真).hashPrefix( '!'); $路由
HTML
<head >
<meta charset="UTF-8">
<base href="/">
<meta name="fragment" content="!">