Web 开发

防止某个页面被Google收录

防止某个页面被Google收录,只要在页面头上加入如下内容即可:

  • 不允许被索引
  1. <meta name="robots" content="noindex,follow" />不允许所有网站收录
  2. <meta name="googlebot" content="noindex, nofollow" />不允许Google收录
  3. <meta name="msnbot" content="noindex, nofollow" />不允许MSN收录

WordPress的插件使用-添加自定义社会标签到Sociable中

Adding a site to Sociable(添加自定义社会标签到Sociable中)
具体效果可查看:http://www.yong3g.com/

首先从http://yoast.com/wordpress/sociable/下载插件;
1. 下载16x16的图片到目录sociable/images/directory。
2. 打开 sociable.php。
3. 查找数组$sociable_known_sites。
4. Copy / paste the code for another site (they're in alphabetical order).
5. Change the value of favicon to the name of your image file.

偶用到的CURL函数

代码:
# $url = "http://www.netps.cn";
# $ch = curl_init();
# curl_setopt($ch, CURLOPT_URL, $url);
# curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

1、resource curl_init ( [string url])
The curl_init() will initialize a new session and return a CURL handle for use with the curl_setopt(), curl_exec(), and curl_close() functions. If the optional url parameter is supplied then the CURLOPT_URL option will be set to the value of the parameter. You can manually set this using the curl_setopt() function.

2、bool curl_setopt ( resource ch, string option, mixed value)

偶遇到的php函数

1、function nl2br($str)
功能:Inserts HTML line breaks before all newlines in a string
示例:<?php echo nl2br("foo isn't\n bar"); ?>
结果:\n会被HTML的换行替换

重定向状态代码

重定向可以被串联,老版本的RFC2616规定重定向最多不超过5次,一般使用时不要超过3次。

重定向状态代码
状态代码 描述 实现
300 多个选择  
301 永久转移 .htaccess:
RewriteRule ^foo\.php$ /bar.php [R=301,L]
或PHP(如果只有Location而没301状态,相当于302临时重定向):
header('HTTP/1.1 301 Moved Permanently');
header('Location:http://www.netps.cn/bar.php');

htaccess文件配置说明

RewriteEngine on
功能:打开url_rewriter功能,mod_rewrite

RewriteCond %{HTTP_HOST} !^www\.netps\.cn
RewriteRule ^(.*)$ http://www\.netps\.cn/$1 [R=301,L]
功能:把不是www.netps.cn的域名指向www.netps.cn

RewirteRule参数说明:

RewirteRule 标记 含义 描述
R Redirect 发出一个HTTP重定向
F Forbidden 禁止对URL地址的存取
G Gone 标记URL地址不存在