2008年12月30日星期二

IE6 重复字符的bug及解决方法

当多个浮动的元素彼此跟随,中间加注释的时候,最后一个浮动元素内的文本偶尔会复制到最下面去。学名Duplicate Characters Bug

程序代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="//www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>多了一只猪</title>
</head>
<body>
<div style="width:400px">
<div style="float:left"></div>
<!-- -->
<div style="float:right;width:400px">↓这就是多出来的那只猪</div>
</div>
</body>
</html>


可以通过以下的办法来解决:
   
1、不放置注释。最简单、最快捷的解决方法
   
2、注释不要放置于2个浮动的区块之间。
    
3、将文字区块包含在新的<div></div>之间,如:<div style="float:right;width:400px"><div>↓这就是多出来的那只猪</div>& lt;/div>。
   
4、去除文字区块的固定宽度,与3有相似之处。
   
5、有的人在猪后加一个<br />或者空格,但只是消除现象。
   
6、不要给浮动元素设置多宽度,使其不会到达包含元素的底部,或者对最后一个元素设置margin-right: -3px;或者更小。
   
7、注释可以这样写:<!--[if !IE]>Put your commentary in here...<![endif]-->

2008年12月13日星期六

SEO Analysis

Title Tag Analysis
The maximum number of characters we recommend for this Tag is 60.
Meta Description Tag Analysis
The maximum number of characters we recommend for this Tag is 150.
Meta Keywords Tag Analysis
Our recommended maximum number of characters for this tag is 874.

IMG ALT Tag Analysis
This section is available in the Member's area of our site when using the Web Page Analyzer. Many search engines consider this area when indexing and looking for keywords. Optimizing this area is quite easy when you know what search engines are looking for.
Keyword Density Analysis
This section is available in the Member's area of our site when using the Web Page Analyzer. This is probably one of the most important ranking factors of a Web page and is easily optimized with our Keyword Density Manipulizer™. Not all keyword density tools analyze this properly. In fact, virtually all those we have tested are wrong! Having the right tool is a must. Our tools are developed by full text search engine development engineers. Getting the wrong information can mean complete SEO failure.

Top Keyword Phrase Analysis
This section is available in the Member's area of our site when using the Web Page Analyzer. Two and three word phrases account for more than 55% of searches done using major search engines as published by Rackstat.com. Properly optimizing for this can net you a ton of additional traffic you may be missing out on. Our two and three word phrase analysis reports helps you to identify and capitalize on this easly.

2008年12月12日星期五

Mysql enum & int 使用情况 (mysql没有必要枚举整型)

写程序时如果用到数据库建议向sqlite看齐,sqlite可没有enum.

Enum: 多用于固定不变的一些数据内容
比如:周一,周二,周三,,,,,,周日

Tinyint: 多用于表示状态(0,1,2,3....), 性能上来说不比 enum差.

Enum存取数据内容时是整型数据,也会把数据转为字符串来处理.
Tinyint存取是整型就是整型.


另外:
数据表有字段: Status enum('0','1','2','3') default 0;

update table set `Status`=0; //这时查看数据内容结果 Status='';

如果Status tinyint default 0; //同样操作数据内容就是 Statsus=0;


-------------------------------------------------------------------

mysql没有必要枚举整型

有些人习惯地把一些状态表示为整型,在mysql存储这些整型时,却转化成字符串,存在了枚举型的列中。这是不必要的。因为在mysql存储这

些枚举字符串时是把这样字符串做一个序列(index),然后存储相应的index值,比如

Enum_value index
NULL NULL 如果NULL是被允许的话
'' 0 一切在在插入时,被视为非法值的字符串,插入的都为空
'a' 1
'b' 2
... ...

也就是说,我们在插入值时,是插入的'a','b'等等字符串,但Mysql真正存储是则是右边的index.如果真得左边的ENUM也为整型值,则是不可取的。因为:
If you store a number into an ENUM column, the number is treated as an index, and the value stored is the enumeration member

with that index. (However, this does not work with LOAD DATA, which treats all input as strings.) It's not advisable to

define an ENUM column with enumeration values that look like numbers, because this can easily become confusing. For example,

the following column has enumeration members with string values of '0', '1', and '2', but numeric index values of
1, 2, and 3.

ENUM的最多的个数也证明了这一点。
An enumeration can have a maximum of 65,535 elements.

同时,都知道程序的需求变化很快,尤其是WEB类的脚本程序。ENUM在表示状态时,也会面临着扩展状态所带来困扰。你必须改变表结构新的值被允许存入。

建议:表示状态类的最好用TINYINT。枚举不是不行,但至少它不是最好。

2008年12月10日星期三

Internet Explorer 中的 Cookie 的数字和大小限制

Microsoft Internet Explorer complies with following RFC 2109 recommended minimum limitations:

* 至少 300 Cookie
* 至少为 4096 字节每个 Cookie (如度量由组成 Cookie 非终端 Set-Cookie 标头的语法描述中字符的大小)
* 每个唯一的主机或域名称至少 20 个 Cookie

注意 these recommended minimum limitations appear in RFC 2109,section 6.3,"Implementation Limits"。 有关详细信息,请参见"参考"一节。

每个 Cookie 开头名称-值对。 此对之后通过零或用分号分隔的多个属性-值对。 为一个域名称,每个 Cookie 被限制为 4,096 字节。 这个总数可以作为一个名称-值对的 4 千字节 (KB) 存在或为最多 20 个名称 / 值对的总 4 KB。如果计算机没有足够的空间来存储 Cookie,该 Cookie 将被丢弃。 则不截尾取整。 应用程序应使用尽可能少的 Cookie 可能作为小型和一个 Cookie 尽可能。 此外,应用程序应该能够处理 Cookie 的丢失。

如果 Web 应用程序使用多个 19 自定义 Cookie,ASP 会话状态可能会丢失。 Internet Explorer 4.0 和更高版本允许每个域的 20 个 Cookie 总共。 因为如果您使用 20 个或更多自定义 Cookie ASPSessionID 是一个 Cookie,在浏览器被强制删除 ASPSessionID Cookie 并丢失该会话。

若要存储超过 20 个名称 / 值对域的可以通过连接多达该 Cookie 4,096 字节的限制每个 Cookie 几个名称 / 值对创建 Cookie 字典。当前,以便从客户端脚本中检索这些值,您必须分析 Cookie 手动。 但是,Active Server Pages 请求 和 响应 对象包括内置功能使用 Cookie 词典作为词典对象。 following sample code demonstrates of in ASP page cookie dictionary use:


%
Response.Cookies ("MyCookie")("a")="A"
Response.Cookies ("MyCookie")("b")="B"
Response.Cookies ("MyCookie")("c")="C"
Response.Cookies ("MyCookie")("d")="D"
Response.Cookies ("MyCookie")("e")="E"
Response.Cookies ("MyCookie")("f")="F"
Response.Cookies ("MyCookie")("g")="G"
Response.Cookies ("MyCookie")("h")="H"
Response.Cookies ("MyCookie")("i")="I"
Response.Cookies ("MyCookie")("j")="J"
Response.Cookies ("MyCookie")("k")="K"
Response.Cookies ("MyCookie")("l")="L"
Response.Cookies ("MyCookie")("a1")="A"
Response.Cookies ("MyCookie")("b1")="B"
Response.Cookies ("MyCookie")("c1")="C"
Response.Cookies ("MyCookie")("d1")="D"
Response.Cookies ("MyCookie")("e1")="E"
Response.Cookies ("MyCookie")("f1")="F"
Response.Cookies ("MyCookie")("g1")="G"
Response.Cookies ("MyCookie")("h1")="H"
Response.Cookies ("MyCookie")("i1")="I"
Response.Cookies ("MyCookie")("j1")="J"
Response.Cookies ("MyCookie")("k1")="K"
Response.Cookies ("MyCookie")("l1")="L"

Response.Cookies("MyCookie").Expires = "12/31/2001"


For Each strKey In Request.Cookies
Response.Write strKey & " = " & Request.Cookies(strKey) & "

"
If Request.Cookies(strKey).HasKeys Then
For Each strSubKey In Request.Cookies(strKey)
Response.Write "->" & strKey & "(" & strSubKey & ") = " & _
Request.Cookies(strKey)(strSubKey) & "
"
Next
End If
Next
%


Note In Internet Explorer 5.0 and later,can use userData behavior to across sessions persist data. this behavior has greater than cookies capacity。

如果您使用 document.cookie 属性来检索该 Cookie 在客户端,将 document.cookie 属性可以检索仅 4,096 字节。 这个字节总数可以是 4 KB,一名称 / 值对或它可以是具有总大小为 4 KB 的最多 20 个名称 / 值对。

document.getcookie 函数在 Microsoft HTML 中调用 CDocument::GetCookie 方法。

for more information,click to view in Microsoft Knowledge Base article following article number:
820536 Document.Cookie 属性返回一个空字符串

官方看:http://support.microsoft.com/kb/306070/zh-cn

2008年12月8日星期一

PHP 从m个数中任取n个数的排列组合算法

从m个数中任取n个数的排列组合算法!

$n = array(1,2,3,4,5,6,7,8,9,10);
//$n = array(1,2,3,4);
/**
$n 数据数组
$m 组合串的长度
$s 用于缓存中间量
**/
function permutation($n, $m = 0, $s = ''){
static $results = array();

if($m == 0) {
$results[] = substr($s,1);//如果长度够了则赋值
}else {
for($i=0; $i < count($n); $i++) {
//echo "==$i===>".$s."\n";
permutation($n, $m-1, $s.','.$n[$i]);
}
}
return $results;
}

$t1 = microtime(true);
$rst = permutation($n, 2);
echo microtime(true) - $t1 ."\n";
//print_r($rst);

//////////////////
function combination($params){
foreach($params as $key => $val) {
$tmpArr = explode(',', $val);
if( 1 == count(array_unique($tmpArr))) {
continue;
}
sort($tmpArr);
$results[] = implode(',', $tmpArr);
}
$results = array_unique($results);

return $results;
}

$s = combination($rst);

print_r($s);
//exit;
function getCombinationCount($n, $k) {
//fscanf(STDIN,"%d,%d",$n,$k);
$r = 1;
while($k) $r *= $n--/$k--;
return $r;
}

echo count($s) . "===========" . getCombinationCount(10, 2);


exit;


加添一个快上N倍的算法:

var_dump(c(range(1,5), 2));

function c($ar,$n){
$c = count($ar);
if ($n>$c) return false; // parameter wrong
if ($c>50) return false; // too big array :)

$r = array();

$code = "";
$list = array();
for($i=1;$i<=$n;$i++){
$list[] = '$v'.$i;
$code .= 'foreach($ar as $k'.$i.'=>$v'.$i.'){';
if($i!=$n) $code .= 'unset($ar[$k'.$i.']);';
}
$code .= '$t = array('.join(',',$list).');';
$code .= 'sort($t);';
$code .= '$r[] = join(",",$t);';
for($i=$n-1;$i>0;$i--){
$code .= '}$ar[$k'.$i.']=$v'.$i.';';
}
$code .= '}';
/*
foreach($ar as $k1=>$v1){
unset($ar[$k1]);
foreach($ar as $k2=>$v2){
unset($ar[$k2]);
foreach($ar as $k3=>$v3){
$t = array($v1,$v2,$v3);
sort($t);
$r[] = join(',',$t);
}
$ar[$k2] = $v2;
}
$ar[$k1] = $v1;
}
*/
eval($code);
return array_values(array_unique($r));
}


再提供一下比快 N倍更快十倍的方法:
function array_combination(array $elements, $chosen)
{
$result = array();

for ($i = 0; $i < $chosen; $i++) { $vecm[$i] = $i; }
for ($i = 0; $i < $chosen-1; $i++) { $vecb[$i] = $i; }
$vecb[$chosen - 1] = count($elements) - 1;
$result[] = $vecm;

$mark = $chosen - 1;
while (true) {
if ($mark == 0) {
$vecm[0]++;
$result[] = $vecm;
if ($vecm[0] == $vecb[0]) {
for ($i = 1; $i < $chosen; $i++) {
if ($vecm[$i] < $vecb[$i]) {
$mark = $i;
break;
}
}
if (($i == $chosen) && ($vecm[$chosen - 1] == $vecb[$chosen - 1])) { break; }
}
} else {
$vecm[$mark]++;
$mark--;
for ($i = 0; $i <= $mark; $i++) {
$vecb[$i] = $vecm[$i] = $i;
}
$vecb[$mark] = $vecm[$mark + 1] - 1;
$result[] = $vecm;
}
}

return $result;
}


ini_set('memory_limit', '328M');
$n = 640 ; $m =2; $elements = range(1, $n);
$begin = microtime(TRUE);
$result = array_combination($elements, $m);
$end = microtime(TRUE);
echo "count: ".count($result) . PHP_EOL;
echo "time: ". 1000*($end-$begin) . " ms" . PHP_EOL;

echo '
';
//print_r($result);
echo '
';

/* output result
foreach($result as $indexes) {
foreach ($indexes as $index) {
echo $elements[$index] . "\t";
}

echo PHP_EOL;
}

*/

2008年12月7日星期日

JS 里用正则表达式替换字符串

方法如下:


//参数中的 g 表示全部匹配,i表示忽略大小写
//str='toaction=t23rue';
//str='toaction=t23rue';
str='toactioN=True';
str=str.replace(/toaction=[\w]+/gi,'toaction=false');
alert(str);


举一个使用的下面一个例子:


function addQueryString()
{
// thickbox query string
var tbString = $_('compStart').alt;

if($_('toaction').checked) tbString = tbString.replace(/toaction=[\w]+/gi,'toaction=true');
else tbString = tbString.replace(/toaction=[\w]+/gi,'toaction=false');

if($_('towinner').checked) tbString = tbString.replace(/towinner=[\w]+/gi,'towinner=true');
else tbString = tbString.replace(/towinner=[\w]+/gi,'towinner=false');

$_('compStart').alt=tbString;
}

Javascript 获取链接(url)参数的方法

摘要: 有时我们需要在客户端获取链接参数,一个常见的方法是将链接当做字符串,按照链接的格式分解,然后获取对应的参数值。本文给出的就是这个流程的具体实现方法。

当然,我们也可以用正则直接匹配,文章中也给出了一个正则的例子。

用正则匹配的方式:
Javascript:
<script language="JavaScript">
<!--
function getQueryStringRegExp(name)
{
var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s|&|$)", "i");
if (reg.test('http://localhost/test.html?aa=bb&test=cc+dd&ee=ff')) {
return unescape(RegExp.$2.replace(/\+/g, " "));
}
return '';
};
//http://localhost/test.html?aa=bb&test=cc+dd&ee=ff
alert(getQueryStringRegExp('test'));
//-->
</script>


分解链接的方式:
Javascript:
<script type="text/javascript">
<!--
// 说明:Javascript 获取链接(url)参数的方法
// 整理:http://www.CodeBit.cn

function getQueryString(name)
{
// 如果链接没有参数,或者链接中不存在我们要获取的参数,直接返回空
if(location.href.indexOf("?")==-1 || location.href.indexOf(name+'=')==-1)
{
return '';
}

// 获取链接中参数部分
var queryString = location.href.substring(location.href.indexOf("?")+1);

// 分离参数对 ?key=value&key2=value2
var parameters = queryString.split("&");

var pos, paraName, paraValue;
for(var i=0; i<parameters.length; i++)
{
// 获取等号位置
pos = parameters[i].indexOf('=');
if(pos == -1) { continue; }

// 获取name 和 value
paraName = parameters[i].substring(0, pos);
paraValue = parameters[i].substring(pos + 1);

// 如果查询的name等于当前name,就返回当前值,同时,将链接中的+号还原成空格
if(paraName == name)
{
return unescape(paraValue.replace(/\+/g, " "));
}
}
return '';
};

//http://localhost/test.html?aa=bb&test=cc+dd&ee=ff
alert(getQueryString('test'));
//-->
</script>

jquery 对 checkbox 实现全选效果 (checkbox控制 | button控制)

以下有两种方法:
1. 使用 checkbox 进行控制 全选checkbox
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> Jquery click all </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<input type="checkbox" id="checkbox1" name="checkbox1" onClick="clickall(this);" >
<input type="checkbox" id="checkname1" name="checkname[]" value="1"/>1
<input type="checkbox" id="checkname2" name="checkname[]" value="2"/>2


<script type="text/javascript" language="javascript">
function clickall(cb){
if(cb.checked) {
$('input[@name="checkname[]"]').attr('checked',true);
} else {
$('input[@name="checkname[]"]').attr('checked',false);
}
}
</script>
</body>
</html>


2. 使用 Button 进行控制 全选checkbox
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> Jquery click all </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
$("#checkall").click(function() {
$("input[@name='checkname[]']").each(function() {
$(this).attr("checked", true);
});
});
$("#delcheckall").click(function() {
$("input[@name='checkname[]']").each(function() {
$(this).attr("checked", false);
});
});
});
</script>
<input type='checkbox' id='id1' name='checkname[]' value='1' />value1
<input type='checkbox' id='id2' name='checkname[]' value='2' />value2
<input type='checkbox' id='id3' name='checkname[]' value='3' />value3
<input type="button" id="checkall" name="checkall" value="全选" />
<input type="button" id="delcheckall" name="delcheckall" value="取消全选" />
</body>
</html>

在js中声明变量时,什么时候需要var,什么时候不需要?

在js中声明变量时,什么时候需要var,什么时候不需要???

关键问题:
在function内部,用var是局部变量,不用var是全局变量。
这个问题不搞清楚,就不是风格的好坏了,可能会导致功能错误。
在function外,用不用都是全局变量。

理解“JS变量定义”的概念

首先,那种不用var就直接赋值的做法,javascript认为你第一次赋值的同时也就是做了定义。如果你是初学者,我建议不妨将这种做法看作一种不规范用法,你就当它根本不存在,问题就简单了。

var aString;
是纯粹的变量定义(但只能在函数内部用)

var aString = "100";
是变量定义,并同时赋值。在函数外部必须这么用,如果在函数内部,就等效于:
var aString;
aString = "100";

赋值可以无数次,定义只能一次!就好比一个人的性格可以不断改变,但出生只能有一次!

2008年12月4日星期四

apache rewrite Rule 详解

作为RewriteRule指令的第三个参数, Flags是一个包含以逗号分隔的下列标记的列表:

'redirect|R [=code]' (强制重定向 redirect)
以 http://thishost[:thisport]/(使新的URL成为一个URI) 为前缀的Substitution可以强制性执行一个外部重定向。
如果code没有指定,则产生一个HTTP响应代码302(临时性移动)。
如果需要使用在300-400范围内的其他响应代码,只需在此指定这个数值即可.
另外,还可以使用下列符号名称之一: temp (默认的), permanent, seeother. 用它可以把规范化的URL反馈给客户端.
如, 重写``/~''为 ``/u/'',或对/u/user加上斜杠,等等。

注意: 在使用这个标记时,必须确保该替换字段是一个有效的URL! 否则,它会指向一个无效的位置! 并且要记住,此标记本身只是对URL加上 http://thishost[:thisport]/的前缀,重写操作仍然会继续。通常,你会希望停止重写操作而立即重定向,则还需要使用'L'标记.

'forbidden|F' (强制URL为被禁止的 forbidden)
强制当前URL为被禁止的,即,立即反馈一个HTTP响应代码403(被禁止的)。
使用这个标记,可以链接若干RewriteConds以有条件地阻塞某些URL。

'gone|G' (强制URL为已废弃的 gone)
强制当前URL为已废弃的,即,立即反馈一个HTTP响应代码410(已废弃的)。
使用这个标记,可以标明页面已经被废弃而不存在了.

'proxy|P' (强制为代理 proxy)
此标记使替换成分被内部地强制为代理请求,并立即(即, 重写规则处理立即中断)把处理移交给代理模块。
你必须确保此替换串是一个有效的(比如常见的以 http://hostname开头的)能够为Apache代理模块所处理的URI。
使用这个标记,可以把某些远程成分映射到本地服务器名称空间,从而增强了ProxyPass指令的功能。
注意: 要使用这个功能,代理模块必须编译在Apache服务器中。如果你不能确定,可以检查``httpd -l''的输出中是否有mod_proxy.c。 如果有,则mod_rewrite可以使用这个功能;如果没有,则必须启用mod_proxy并重新编译``httpd''程序。

'last|L' (最后一个规则 last)
立即停止重写操作,并不再应用其他重写规则。
它对应于Perl中的last命令或C语言中的break命令。这个标记可以阻止当前已被重写的URL为其后继的规则所重写。
举例,使用它可以重写根路径的URL('/')为实际存在的URL, 比如, '/e/www/'.

'next|N' (重新执行 next round)
重新执行重写操作(从第一个规则重新开始). 这时再次进行处理的URL已经不是原始的URL了,而是经最后一个重写规则处理的URL。
它对应于Perl中的next命令或C语言中的continue命令。
此标记可以重新开始重写操作,即, 立即回到循环的头部。
但是要小心,不要制造死循环!

'chain|C' (与下一个规则相链接 chained)
此标记使当前规则与下一个(其本身又可以与其后继规则相链接的, 并可以如此反复的)规则相链接。
它产生这样一个效果: 如果一个规则被匹配,通常会继续处理其后继规则, 即,这个标记不起作用;如果规则不能被匹配,则其后继的链接的规则会被忽略。
比如,在执行一个外部重定向时, 对一个目录级规则集,你可能需要删除``.www'' (此处不应该出现``.www''的)。

'type|T=MIME-type' (强制MIME类型 type)
强制目标文件的MIME类型为MIME-type。
比如,它可以用于模拟mod_alias中的ScriptAlias指令, 以内部地强制被映射目录中的所有文件的MIME类型为``application/x-httpd-cgi''.

'nosubreq|NS' (仅用于不对内部子请求进行处理 no internal sub-request)
在当前请求是一个内部子请求时,此标记强制重写引擎跳过该重写规则。
比如,在mod_include试图搜索可能的目录默认文件(index.xxx)时, Apache会内部地产生子请求。
对子请求,它不一定有用的,而且如果整个规则集都起作用,它甚至可能会引发错误。
所以,可以用这个标记来排除某些规则。

根据你的需要遵循以下原则: 如果你使用了有CGI脚本的URL前缀,以强制它们由CGI脚本处理, 而对子请求处理的出错率(或者开销)很高,在这种情况下,可以使用这个标记。

'nocase|NC' (忽略大小写 no case)
它使Pattern忽略大小写,即, 在Pattern与当前URL匹配时,'A-Z' 和'a-z'没有区别。

'qsappend|QSA' (追加请求串 query string append)
此标记强制重写引擎在已有的替换串中追加一个请求串,而不是简单的替换。
如果需要通过重写规则在请求串中增加信息,就可以使用这个标记。

'noescape|NE' (在输出中不对URI作转义 no URI escaping)
此标记阻止mod_rewrite对重写结果应用常规的URI转义规则。
一般情况下,特殊字符(如'%', '$', ';'等)会被转义为等值的十六进制编码。
此标记可以阻止这样的转义,以允许百分号等符号出现在输出中,
如:
RewriteRule /foo/(.*) /bar?arg=P1\%3d$1 [R,NE]

可以使'/foo/zed'转向到一个安全的请求'/bar?arg=P1=zed'.

'passthrough|PT' (移交给下一个处理器 pass through)
此标记强制重写引擎将内部结构request_rec中的uri字段设置为 filename字段的值,它只是一个小修改,使之能对来自其他URI到文件名翻译器的 Alias,ScriptAlias, Redirect 等指令的输出进行后续处理。
举一个能说明其含义的例子: 如果要通过mod_rewrite的重写引擎重写/abc为/def,然后通过mod_alias使/def转变为/ghi,可以这样:
RewriteRule ^/abc(.*) /def$1 [PT]
Alias /def /ghi

如果省略了PT标记,虽然mod_rewrite运作正常, 即, 作为一个使用API的URI到文件名翻译器, 它可以重写uri=/abc/...为filename=/def/..., 但是,后续的mod_alias在试图作URI到文件名的翻译时,则会失效。
注意: 如果需要混合使用不同的包含URI到文件名翻译器的模块时, 就必须使用这个标记。。 混合使用mod_alias和mod_rewrite就是个典型的例子。

For Apache hackers
如果当前Apache API除了URI到文件名hook之外,还有一个文件名到文件名的hook, 就不需要这个标记了! 但是,如果没有这样一个hook,则此标记是唯一的解决方案。
Apache Group讨论过这个问题,并在Apache 2.0 版本中会增加这样一个hook。

'skip|S=num' (跳过后继的规则 skip)
此标记强制重写引擎跳过当前匹配规则后继的num个规则。
它可以实现一个伪if-then-else的构造: 最后一个规则是then从句,而被跳过的skip=N个规则是else从句. (它和'chain|C'标记是不同的!)

'env|E=VAR:VAL' (设置环境变量 environment variable)
此标记使环境变量VAR的值为VAL, VAL可以包含可扩展的反向引用的正则表达式$N和%N。
此标记可以多次使用以设置多个变量。
这些变量可以在其后许多情况下被间接引用,但通常是在XSSI (via ) or CGI (如 $ENV{'VAR'})中, 也可以在后继的RewriteCond指令的pattern中通过%{ENV:VAR}作引用。
使用它可以从URL中剥离并记住一些信息。

'cookie|CO=NAME:VAL:domain[:lifetime[:path]]' (设置cookie)
它在客户端浏览器上设置一个cookie。
cookie的名称是NAME,其值是VAL。
domain字段是该cookie的域,比如'.apache.org', 可选的lifetime是cookie生命期的分钟数, 可选的path是cookie的路径。
注意
绝不要忘记,在服务器级配置文件中,Pattern是作用于整个URL的。 但是在目录级配置文件中, (一般总是和特定目录名称相同的)目录前缀会在pattern匹配时被自动删除,而又在替换完毕后自动被加上。此特性对很多种重写是必须的,因为,如果没有这个剥离前缀的动作,就必须与其父目录去匹配,而这并不总是可行的。
但是有一个例外: 如果替换串以``http://''开头, 则不会附加目录前缀, 而是强制产生一个外部重定向,或者(如果使用了P标记)是一个代理操作!

注意
为了对目录级配置启用重写引擎,你必须在这些文件中设置``RewriteEngine On'', 并且打开``Options FollowSymLinks'。
如果管理员对用户目录禁用了FollowSymLinks, 则无法使用重写引擎。这个限制是为了安全而设置的。

以下是所有可能的替换组合及其含义:

在服务器级配置中(httpd.conf),对这样一个请求 ``GET /somepath/pathinfo'':


Given Rule Resulting Substitution
---------------------------------------------- ----------------------------------
^/somepath(.*) otherpath$1 not supported, because invalid!
^/somepath(.*) otherpath$1 [R] not supported, because invalid!
^/somepath(.*) otherpath$1 [P] not supported, because invalid!
---------------------------------------------- ----------------------------------
^/somepath(.*) /otherpath$1 /otherpath/pathinfo
^/somepath(.*) /otherpath$1 [R] http://thishost/otherpathvia external redirection
^/somepath(.*) /otherpath$1 [P] not supported, because silly!
---------------------------------------------- ----------------------------------
^/somepath(.*) http://thishost/otherpath$1 /otherpath/pathinfo
^/somepath(.*) http://thishost/otherpath$1 [R] http://thishost/otherpathvia external redirection
^/somepath(.*) http://thishost/otherpath$1 [P] not supported, because silly!
---------------------------------------------- ----------------------------------
^/somepath(.*) http://otherhost/otherpath$1 http://otherhost/otherpath/pathinfovia external redirection
^/somepath(.*) http://otherhost/otherpath$1 [R] http://otherhost/otherpath/pathinfovia external redirection (the [R] flag is redundant)

^/somepath(.*) http://otherhost/otherpath$1 [P] http://otherhost/otherpath/pathinfovia internal proxy

在/somepath的目录级配置中
(即, 目录/physical/path/to/somepath的.htaccess文件中包含 RewriteBase /somepath)
对这样一个请求``GET /somepath/localpath/pathinfo'':

Given Rule Resulting Substitution
---------------------------------------------- ----------------------------------
^localpath(.*) otherpath$1 /somepath/otherpath/pathinfo
^localpath(.*) otherpath$1 [R] http://thishost/somepath/otherpath/pathinfovia external redirection
^localpath(.*) otherpath$1 [P] not supported, because silly!
---------------------------------------------- ----------------------------------
^localpath(.*) /otherpath$1 /otherpath/pathinfo
^localpath(.*) /otherpath$1 [R] http://thishost/otherpath/pathinfovia external redirection
^localpath(.*) /otherpath$1 [P] not supported, because silly!
---------------------------------------------- ----------------------------------
^localpath(.*) http://thishost/otherpath$1 /otherpath/pathinfo
^localpath(.*) http://thishost/otherpath$1 [R] http://thishost/otherpath/pathinfovia external redirection
^localpath(.*) http://thishost/otherpath$1 [P] not supported, because silly!
---------------------------------------------- ----------------------------------
^localpath(.*) http://otherhost/otherpath$1 http://otherhost/otherpath/pathinfovia external redirection
^localpath(.*) http://otherhost/otherpath$1 [R] http://otherhost/otherpath/pathinfovia external redirection(the [R] flag is redundant)
^localpath(.*) http://otherhost/otherpath$1 [P] http://otherhost/otherpath/pathinfovia internal proxy


举例:

要重写这种形式的URL:
/ Language /~ Realname /.../ File

/u/ Username /.../ File . Language

可以把这样的对应关系保存在/path/to/file/map.txt映射文件中, 此后,只要在Apache服务器配置文件中增加下列行,即可:

RewriteLog /path/to/file/rewrite.log
RewriteMap real-to-user txt:/path/to/file/map.txt
RewriteRule ^/([^/]+)/~([^/]+)/(.*)$ /u/${real-to-user:$2|nobody}/$3.$1

SEO常用名词

SEO常用名词
与Source Code有关的SEO常用语:
1. Title Tag /Meta Title
<title>Smarter.com Comparison Shopping: Compare Prices, Discounts & Reviews on Millions of Products</title>
2. Meta Description
<Meta NAME="description" content="Shop and save at Smarter.com: Compare prices, coupons and rebates from thousands of online stores to get the lowest price. Before you buy, see products up-close in video reviews. Read shopping blogs, buying guides and unbiased product and website reviews to find out how other consumer's rate their purchases. There are millions of items for sale online. Comparison shop to find the right one for you at the best prices on the Internet." />
3. Meta Keyword
<meta NAME="keywords" content="comparison shopping, compare prices, product reviews, merchant reviews, compare products, shop and compare, best price, purchase and buy online, shop & save, store, shop at home, Smarter.com, site, internet, links, cost, website, consumer information, service" />
4. Other Meta Tag:
<meta content="index,follow" name="robots" />
<META NAME="ROBOTS" CONTENT="NOYDIR">
<META NAME="ROBOTS" CONTENT="NOODP">
<META name="y_key" content="5308ed89f65f99e8" />
<meta content="www.smarter.com" name="copyright" />

5. Meta Tag
Meta Title + Meta Description + Meta Keyword
6. H Tag/Header Tag
<H1>…</H1>, <H2>…</H2> etc.
7. Alt Tag
alt=” ” (适用于图片), title=””(适用于文字链接)
8. List Tag
<ul>, <ol>, <li> and <dl>, <dt>, <dd> etc.
9. Frame Tag
<frame>, <iframe>, <frameset> etc.
10. Nofollow Tag
<a href="/email.php?url=aHR0cDovL3d3dy5zbWFydGVyLmNvbS8=" rel="nofollow" >Email this Page</a>
11. <P> Tag
<p>Monday I came to you with some expiring Dell deals, and if those didn't spark your interest, maybe this HP deal will.</p>

与SEO技术相关的常用语:
SE - 搜索引擎
SERP - 搜索引擎结果页面
Search Engine Ranking/Ranking - 搜索引擎排名
Keyword Density - 关键词密度
Page Rank (简称PR值) - Google衡量网页重要性的工具,测量值范围为从1至10分别表示某网页的重要性。Google工具栏可以随时获得某网页的PR值。
Inbound Link = External Links (外部链接)- 被其他网站链接的数量
Outbound link - 一个网站链接到其他网站的数量
Internal links (内部链接)- 本网站页面之间的链接
Backward Links(反向链接)= Internal Links + External Links - 外部链接与内部链接的总和
Open Directory Project (简称ODP) - 目录索引网站,如Dmoz,Yahoo,Google
Redirection - 跳转,有301,302两种跳转方式
404/Not Found Page
Link Popularity: 链接广度
友情链接/交换链接/Reciprocal Link
One-way Link
Three-way Link
Paid Link
Hidden Link/Text/Content
SPAM = Link Spam + Content Spam - 在SEO领域里,它指的是一种有目的有计划地提高网站在搜索引擎排名的作弊技术,一旦被发现,网站将会被屏弊
Link Spam - 作弊链接/恶意链接(也有称作:link farms 链接工厂)
Keyword Stuffing - 关键词堆砌
Deceptive redirects 欺骗性重定向 - 指把用户访问的第一个页面(争夺排名页)迅速重定向至另一个内容完全不同的页面。
Shadow Domain - 这是最常见的欺骗性重定向技术,通过欺骗性重定向使用户访问另外一个网站或页面。
Doorway Page 门页- 也叫“桥页”。是为某些关键字特别制作的页面,专为搜索引擎设计,目的是提高特定关键词在搜索引擎中的排名所设计的富含目标关键词的域名,且重定向至另一域名的真实网站。搜索引擎的Spiders往往忽略对那些自动重定向到其它页的页面的检索。
Spider = Robot = Bot = Slurp – 搜索引擎爬虫
Mirror Sites/Duplicate Sites (镜象站点) - 通过复制网站的内容并分配以不同域名和服务器,以此欺骗搜索引擎对同一站点或同一页面进行多次索引。现在大多数搜索引擎都提供有能够检测镜象站点的适当的过滤系统,一旦发觉镜象站点,则原站点和镜象站点都会被从索引数据库中删除。
Duplicate Content - 複製的內容通常指的是一個頁面上的內容是從網上別的地方COPY來的,不努力工作 就想得到好排名。GOOGLE有一套很出名的過濾機制去尋找複製文本,一旦它發現兩個或更多同樣的文本它就會評估這些文檔去看哪一個是他們收錄時間最長 的,最新的網頁會被刪除或排在比較靠後的結果中。

一个强大的屏幕捕捉程序


一个强大的屏幕捕捉程序,不仅能捕捉 Windows 下的屏幕,也能捕捉 DOS 的。存盘支持的图形格式也很多。SnagIt对于系统并不会要求太高,凡Windows 98/95/NT 皆可使用,而且只要有 Windows 支持的打印机,就可以设定打印机输出,若有设定 32 位的 MAPI,还可以以电子邮件方式来输出。

sn:DBMLC-FCB3V-A33GA-JDCYY-ZB387


下载地址:http://www.chinaz.cn/soft/9620.htm