【发布时间】:2023-03-14 10:41:02
【问题描述】:
我在 meanjs 有一个项目。
它禁用了 html5mode,所以我的网址是这样的:
http://localhost:3000/#!/products
我正在尝试实现 AJAX 快照,以允许 Google 爬虫在客户端查看由 javascript 生成的内容。
我安装了一个名为 MEAN-SEO 的模块:
http://blog.meanjs.org/post/78474995741/mean-seo
现在当我访问以下网址时:
http://localhost:3000/?_escaped_fragment_=
我被重定向到:
http://localhost:3000/?_escaped_fragment_=/#!/
当我点击“产品”或直接访问时,我被重定向到:
http://localhost:3000/?_escaped_fragment_=/#!/products
阅读此处详述的 Google 规范后 https://developers.google.com/webmasters/ajax-crawling/docs/getting-started ,我需要的是没有 hashbangs 的东西,如下所示:
http://localhost:3000/?_escaped_fragment_=/products
我做错了什么? 亲切的问候。
【问题讨论】:
-
看起来路由问题是在服务器上正确安装了 mean-seo,就像将代码片段添加到 express.js 中一样?
app.use(seo({ cacheClient: 'disk', // can also be 'redis' but not sure if needed // redisURL: 'url/port', if we were actually using redis cacheDuration: 2 * 60 * 60 * 24 * 1000, // in ms, so I think this is currently set to 2 days }));
标签: ajax seo meanjs google-crawlers