隐藏“重复内容"使用mod_rewrite删除.php文件扩展名后从Google下载 [英] Hide "duplicate content" from Google after using mod_rewrite to remove .php file extension
问题描述
抱歉,标题有些含糊!我会尽力解释.我的.htacess中包含以下内容:
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
因此用户可以键入domain.com/foo/bar
并提供domain.com/foo/bar.php
.当然,键入domain.com/foo/bar.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.
因此,在Google网站站长工具(位于HTML建议下)下,Google认为我已经复制了所有元描述和标题标签,因为它将bar和bar.php视为两个不同的文件.我担心Google会惩罚这种重复内容".我该怎么办?我肯定不是第一个遇到此问题的人,但是我正在努力寻找相关的问题/答案.
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.
感谢您的帮助
推荐答案
我使用的答案(根据我的原始评论)从这里解决了我的问题
The answer i used (as per my original comment) from here which solved my problem
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^.]+\.)+php?\
HTTP RewriteRule (.+)\.php?$ http://www.domain.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(([^/]*/)*[^/.]+)$ /$1.php [L]
这篇关于隐藏“重复内容"使用mod_rewrite删除.php文件扩展名后从Google下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!