剔除奇怪的页面与的.htaccess奇怪、页面、htaccess

2023-09-02 01:08:44 作者:我們還很單純

我有一个奇怪的情况发生在我的网站,谷歌认为某些PHP网页是其他PHP页面的孩子。例如,我得到在谷歌网站管理员工具误差页面显示出来,如:的http://域名。 COM / page1.php中/ page5.php 。无论page1.php中page5.php存在的网站上,但我不明白,为什么谷歌认为应该要连接到其他的。

I have a strange situation occurring on my site where google thinks certain php pages are children of other php pages. For example, I am getting errors in Google Webmaster tools for pages showing up like: http://domain.com/page1.php/page5.php. Both page1.php and page5.php exist on the site, but I can't figure out why google thinks one should be concatenated to the other.

浏览到这样一个链接将加载page1.php中,但不正确。我的目标是使用的.htaccess(或其他建议)简单地重定向到第一页,如果其他页跟随。我在想这个正确的,而且任何人都可以提供建议,以帮助我解决这个?谢谢!

Browsing to such a link will load page1.php, but not correctly. My goal was to use .htaccess (or other suggestions) to simply redirect to the first page if additional pages follow. Am I thinking about this correctly, and can anyone offer suggestions to help me resolve this? Thanks!

更新:在我的.htaccess文件中唯一的行是从previous文件夹结构,以一个单一的PHP文件重定向,但这已经到位了至少一年。例如:

Update: The only lines in my .htaccess file are redirecting from a previous folder structure to a single php file, but this has been in place for at least a year. For example:

RedirectMatch 301 ^ /部件/?$ http://firesage.com/widgets.php

UPDATE2:我刚刚发现网站管理员工具这种软404的错误:的 http://domain.com/page2.php/include/include/lookup.php?id=22 。首先,我有包括文件夹通过的robots.txt排除在外。而且该包含文件夹中的网址列出两次的事实是非常可疑的。

Update2: I just found this 'Soft 404' error in Webmaster tools: http://domain.com/page2.php/include/include/lookup.php?id=22. First, I have the include folder excluded via robots.txt. And the fact that the include folder is listed twice in the url is very suspect.

推荐答案

一般来说,你可以使用的.htaccess 来重定向谷歌,但我宁愿建议你找的理由谷歌认为那些错误的链接(S,吉荣的评论你的问题)。这里的的.htaccess 启动了,直到你找到了原因。

Generally you can use .htaccess to redirect Google, but I would rather suggest you find the reason why Google sees those "wrong" links (s. Jeroen's comment to your question). Here's the .htaccess to start up with, until you've found the reason.

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /
Options +FollowSymLinks

# every page on its own
RewriteRule ^page1.php/(.*)$ /page1.php [R=301,L]
RewriteRule ^page2.php/(.*)$ /page2.php [R=301,L]
# or in general maybe the following to replace all of the above, if you think it'll fit
# RewriteRule ^([^/.]+).php/(.*)$ /$1.php [R=301,L]

</IfModule>

更新 如果您还需要通过任何可能的 GET 参数,只需添加 QSA 标记,使其成为 [R = 301,L,QSA]

Update If you also need to pass any possible GET parameters, just add the QSA flag so it becomes [R=301,L,QSA].