C 使用?\u转义\u片段向Google bot提供index.html_=
我有一个非常重Javascript的应用程序,我想对它进行索引。我的网站上有一个快照目录,可以提供给谷歌机器人。这些都在mysite.com/snapshots/下 我使用以下重写规则将快照提供给Google bot:C 使用?\u转义\u片段向Google bot提供index.html_=,c,nginx,rewrite,googlebot,C,Nginx,Rewrite,Googlebot,我有一个非常重Javascript的应用程序,我想对它进行索引。我的网站上有一个快照目录,可以提供给谷歌机器人。这些都在mysite.com/snapshots/下 我使用以下重写规则将快照提供给Google bot: location / { if ($args ~ "_escaped_fragment_=") { rewrite ^/(.*)$ /snapshots/$1.html break; } } 这适用于除主页之外的所有快照。问题是,主页被保存为my
location / {
if ($args ~ "_escaped_fragment_=") {
rewrite ^/(.*)$ /snapshots/$1.html break;
}
}
这适用于除主页之外的所有快照。问题是,主页被保存为mysite.com/snapshots/index.html
。当Google bot请求mysite.com/?\u转义\u片段
,nginx试图提供/snapshots/.html
,显然是请求404的
我需要调整重写规则,以便在请求文档根目录时提供index.html
干杯 将其添加到服务器配置中,无论在何处,只要在
服务器{}
中即可
location ^= index\.html$ {
try_files $uri =404;
}
这将检查请求的URL是否以
index.html
结尾。如果这不起作用,我需要Google bot请求的完整URL。在重写行上方添加:
rewrite ^/$ /index.html;