隐藏“重复内容”使用 mod_rewrite 删除 .php 文件扩展名后来自 Google
抱歉,这个标题有点神秘!我会尝试解释一下。我的 .htacess 中有以下内容:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
因此用户可以输入 domain.com/foo/bar
并提供 domain.com/foo/bar.php
。当然,输入 domain.com/foo/bar.php
也会加载相同的页面。
因此,在 Google 网站管理员工具(在 HTML 建议下)中,Google 认为我已经复制了所有元描述和标题标签,因为它将 bar 和 bar.php 视为两个不同的文件。我担心谷歌会惩罚这种“重复内容”。我应该怎么办?我确信我不是第一个遇到这个问题的人,但我正在努力寻找相关的问题/答案。
感谢您的帮助
Sorry for the somewhat cryptic title! I'll try to explain. I have the following in my .htacess:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
So users can type domain.com/foo/bar
and domain.com/foo/bar.php
is served. Of course, typing domain.com/foo/bar.php
also loads the same page.
So, in Google Webmaster Tools (under HTML Suggestions), Google thinks that i have duplicated all my meta descriptions and title tags as it sees bar and bar.php as two different files. I am worried Google will penalise this "duplicate content". What should i do? I am sure im not the first one to have this issue, but i am struggling to find related questions/answers.
Thanks for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用[R](重定向标志)。
这会强制进行外部重定向,因此尝试访问domain.com/foo/bar.php的用户将被重定向(通过HTTP 302 Found)到domain.com/foo/bar。您还需要使用 [L](最后一条规则),以便立即发生重定向。
Use [R] (the redirect flag).
This forces an external redirect, so users who attempt to access domain.com/foo/bar.php will be redirected (through HTTP 302 Found) to domain.com/foo/bar. You'll also want to use [L] (last rule), so that the redirect happens immediately.
我使用的答案(根据我原来的评论)从这里解决了我的问题
The answer i used (as per my original comment) from here which solved my problem