【发布时间】:2015-09-21 13:29:24
【问题描述】:
我已遵循以下指南:
角度:
$locationProvider.html5Mode(true);
在 html 中,添加这个元标题:
<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:
【问题讨论】:
-
假设
/products不存在(不是真实文件),您的 htaccess 会将其重写为/index.html。这是正常的行为,所以。你会拿什么来代替?
标签: apache .htaccess google-search