使用 htaccess 重写 URL 以删除首页分页
我有一个分页的文章列表,我的搜索引擎将第一页索引两次为 /articles 和 /articles?start=1。
我想编写一个 .htaccess 重写规则来将对 /articles?start=1 的任何请求重写为 /articles 以阻止这种情况发生。
网站上还有一些其他基于文章的分页列表,因此我需要仅匹配参数而不是完整的 url,以便该规则也适用于这些 url。
感谢您的帮助!
I have an paginated list of articles and my search engine is indexing the first page twice as /articles and /articles?start=1.
I want to write an .htaccess rewrite rule to rewrite any requests for /articles?start=1 to /articles to stop this from happening.
There are a couple of other article based paginated lists on the site, so i need to match just the parameter rather that the full url, so that the rule will work on thse urls also.
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
我假设
articles
是一个目录。Try this:
I am assuming
articles
is a directory.有点死灵,但我只是在寻找其他东西时通过谷歌发现了这个问题。
最近,Google 对 URL 参数如何影响网站索引提供了更多控制。转至 Google 网站站长工具并设置您的网站。
Google 将抓取您的网站并添加其识别的 URL 参数列表(我相信您可以将自己的参数添加到列表中)。您可以指定 URL 参数如何影响您的页面(分页、过滤、内部等),这反过来又告诉 Google 如何对其进行索引。
在这种情况下,您可以说 start 应该被忽略,仅索引一次,或者按照您认为合适的方式进行处理,以确保它仅按照其含义在索引中显示。
这对谷歌有帮助,也对你有帮助,所以这是完全双赢的。
A bit of a necro, but I just found this question via Google when looking for something else.
Recently, Google offered up way more control over how URL parameters affect their indexing of your site. Go to Google Webmaster Tools and set up your site.
Google will crawl your site and add a list of URL parameters its aware of (and I beleive you can add your own to the list). You can specify how the URL parameters affect your page (pagination, filtering, internal etc) which in turn tells Google how to index it.
In this case, you'll be able to say that start should be either ignored, indexed only once, or treated how you see fit to make sure it only appears how its meant to in the index.
This helps Google and also helps you, so its entirely win-win.