gpt4 book ai didi

apache - Prerender.io 子页面重定向到索引

转载 作者:行者123 更新时间:2023-12-02 03:21:59 26 4
gpt4 key购买 nike

我遵循了以下指南:

角度:

$locationProvider.html5Mode(true);

在 html 中,添加此元 header :

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

配置 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

现在我的索引网站终于被谷歌收录了。

但是,每当我尝试访问我的子站点时,它都会告诉我它已被重定向到 index.html

谁能告诉我我做错了什么?我已经尝试了几个星期,但一直无法想出解决方案:(

来自 google-bot-simulator:

enter image description here

最佳答案

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

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

上面列出了将代理到 prerender.io 的所有机器人。更具体地说,它仅列出足以检测到它们的用户代理部分。如果您添加了“googlebot”,那么它也会匹配。或者可能只是出于测试目的的“机器人”。

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

试一试。另外,查看您的浏览器是否有“User Agent Switcher”插件,可以让您比通过谷歌工具更快地进行测试。

关于apache - Prerender.io 子页面重定向到索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32696549/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com