从Google Search 结果列表中删掉网站信息【札记】
网站域名类似于:https://www.config.com.
现在要从Google的搜索结果列表里面删掉所有与该域名相关的结果。
方法一: 添加robots.txt 文件至 https://www.config.com/robots.txt, 即网站根目录
服务器架构如下:
1. 在Apache Server Host 所在主机划了两个虚拟服务器主机:
https://www.config.com 和 https://test.config.com
这两个虚拟服务器的环境都是 Tomcat5.5, 用来运行一系列web 应用。
Apache Server 地址映射到两个不同的主机,都监听在端口8443口上。
1. 登录Google webmaster tool :https://www.google.com/webmasters/tools/home?hl=zh-CN
按照Google的官方文档,如何生成robots.txt 文件,如何生成验证文件:google*.html.
2. 个人认为是最关键的:
将上面生成(robots.txt 也可以自己手动新建,文件名一定要是“robots.txt")的两个文件上传至网站的根目录。
一般情况下,打开https://www.config.com/ 如果没有跳转的话,一般会有个welcome主页显示,将文件上传至主页文件所在目录即可。一般情况下可以是如下目录:
1. Tomcat/webapp/ROOT/
2. Tomcat/webapp/appName/
我这里的做法就是上传至/webapp/appName/下面,做完这一切之后,理论上来说,应该就行了,但是我错了,我的情况和理论情况有很大的出入。
当在浏览器窗口输入: https://www.config.com/robots.tx t时,页面出现了跳转。
于是跑到代码中,将跳转的地方过滤掉。再试。但是出现了404 错误,无法访问txt文件。
于是我把server上的tomcat 原封不动的down下来,放到本地进行测试。
https://localhost/robots.txt
是没有问题的,这就说明tomcat中的配置没有问题。于是很自然的联想到应该是Apache Server 的配置问题。
最后转战Apache Server,编辑apache 的http 配置文件:/etc/httpd/conf/httpd.conf
在如下配置中新增指令:
<VirtualHost *:80>
ServerName www.config.com
DocumentRoot /var/www/html
ErrorLog logs/error_log
CustomLog logs/access_log combined
RewriteEngine On
RewriteRule ^/google(.*)\.html$ /var/www/html/googlebe2e31644183d63e.html [L]
RewriteRule ^/robots\.txt$ /var/www/html/robots.txt [L]
....
</VirtualHost>
并将robots.txt 和 googlexxxx.html 两个文件拷到 DocumentRoot 所对应的目录中,在我这里是: /var/www/html 中。
最后重启apache server。
再次在浏览器窗口中输入: https://www.config.com/robots.txt
发现还是404错误。
但是输入:http://www.config.com/robots.txt
发现运行正常。再次输入:http://www.config.com/googlebe2e31644183d63e.html
也是正常的能够访问,但是换成:【https】就报404错误。
看到这儿,很明显就是ssl.conf中的配置问题了。
于是定位到/etc/httpd/conf.d/ssl.conf 中,新增如下指令:
<VirtualHost *:443>
...
ServerName www.config.com
ProxyPass /robots.txt !
ProxyPassMatch ^/google(.*).html !
....
</VirtualHost>
关于apache 的指令,请参考apache官方文档:
http://httpd.apache.org/docs/current/mod/directives.html
http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypass
Note:
【!】
指令表示不想对某个子目录进行反向代理.
【ProxyPassMatch】指令表示url正则匹配,不仅仅只是简单的前缀匹配。和【ProxyPass】的单一的前缀匹配不同。
http://blog.****.net/fenglibing/article/details/6796094
http://blog.****.net/xxfigo/article/details/11180673
http://www.iteye.com/topic/807101
保存文件后退出,重启apache server。
最后再次在浏览器窗口中输入:
https://www.config.com/robots.txt
http://www.config.com/robots.txt
https://www.config.com/googlebe2e31644183d63e.html
http://www.config.com/googlebe2e31644183d63e.html
四个都运行正常。世界是如此的美好。
特此记录解决这一过程中所出现的一些列问题。
方法二:
在网站主页的index.html 的head标签中添加 <meta> 标签
<meta name="robots" content="noindex,nofollow">
详细的设置信息,可以参考如下文档:
http://www.robotstxt.org/meta.html
http://www.elegantthemes.com/blog/tips-tricks/how-to-stop-search-engines-from-indexing-specific-posts-and-pages-in-wordpress
https://productforums.google.com/forum/#!topic/webmasters/wmy9vTkcIdY