prerender.io子页面重定向到指数 [英] Prerender.io subpages redirect to index

查看:121
本文介绍了prerender.io子页面重定向到指数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照以下指南:

在角:

$locationProvider.html5Mode(true);

在HTML中,添加此元头:

In html, add this meta header:

<head>
    <meta name="fragment" content="!">
</head>

配置Apache:

Configure Apache:

  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 "YOUR_TOKEN"

    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

现在我的索引的网站终于被拾起谷歌。

Now my index site is finally being picked up by google.

不过,每当我尝试去我的子网站,它告诉我,它已被重定向到 index.html的

HOWEVER whenever i attempt to go to my subsite it tells me that it has been redirected to index.html

谁能告诉我什么即时做错了什么?我已经尝试本作周,处理不当能拿出一个解决方案:(

Can anyone please tell me what im doing wrong? i have attempted this for weeks and hasnt been able to come up with a solution :(

谷歌机器人模拟器

输入图像的描述在这里

推荐答案

您正在测试您的网站Googlebot的,但用户代理是不是在你的重写规则正在寻找可能的用户代理的列表。

You are testing your site with Googlebot, but that user agent is not in the list of possible user agents that your Rewrite rules are looking for.

RewriteCond %{HTTP_USER_AGENT} baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest [NC,OR]

上面列出了所有将要代理到prerender.io的机器人。更具体地说,它列出只是部分用户代理,足以探测到它们的。如果您添加了Googlebot的',那么它会匹配这一点。或者$ P $用于测试目的phaps只是'机器人'。

The above lists all the bots that will be proxied to prerender.io. More specifically it lists just parts of the user agent that is enough to detect them. If you added 'googlebot' then it would match that as well. Or prehaps just 'bot' for testing purposes.

RewriteCond %{HTTP_USER_AGENT} bot|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest [NC,OR]

试试看吧。另外,看看您的浏览器有一个用户代理切换器插件,它可以让你不是通过谷歌工具测试速度更快。

Give it a try. Also, see if your browser has a 'User Agent Switcher' plugin that would let you test quicker than going through the google tools.

这篇关于prerender.io子页面重定向到指数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆