本文主要介绍将URL长度简化为1.html、f2等的方法。由PHPwind伪静态,可以参考。
1。。根目录下的htaccess(规则适用于iis,其他nginx和apache要稍微修改一下)
重写引擎on
重写规则f(\d+)_(。*)_(.*)$/thread.php?fid=$1&page=$2&type=$3[L]
RewriteRulef(\d+)_(。*)$/thread.php?fid=$1&page=$2[L]
RewriteRulef(\d+)$/thread.PHP?FID=$1[L]
RewriteRule(\d+)_(。*)_(.*)_(.*).html$/read.php?tid=$1&page=$2&fpage=$3&uid=$4[L]
RewriteRule(\d+)_(。*)_(.*).html$/read.php?tid=$1&page=$2&fpage=$3[L]
RewriteRule(\d+)_(。*).html$/read.php?tid=$1&page=$2[L]
RewriteRule(\d+)。html/read.php?重写者^(.*)-htm-(。*)$.php?$2[L]
RewriteRule/simple/([a-z0-9\_]+)\。html$/simple/index\。php\?[L]
2在require/common.php
中找到
函数URL重写($URL)并替换为:
函数URL重写($URL){
全局
if(!$db_htmifopen)返回$url
如果(!preg_match('/^(http|ftp|telnet|mms|rtsp)|admin.php|rss.php/i',$url)){
$add=strpos($url,'#')!==假的?substr($url,strpos($url,'#'):'';
if(strpos($url,'thread.php?')!==false){
unset($rw);
$tharr=explode('&;'),substr(str_replace($add,'',$url),11));
foreach($tharras$key=>;$value){
$ru=explode('=',$value,3);
if($ru['1']){
switch($ru['0']){
case'FID':
$rw['FID']=$ru['1'];
$rw['para']<;1&&$rw['para']=1;
break;
case'page':
$rw['page']=$ru['1'];
$rw['para']<;2&&$rw['para']=2;
break;
case'type':
$rw['type']=$ru['1'];
$rw['para']<;4&&$rw['para']=4;
break;
默认值:
$rw['para']=8;
$URLfail=1;
break;
}
}
}
switch($rw['para']){
case'1':
$URL="f"。$rw['FID'];
break;
事例“2”:
$URL="f"。$rw['fid']。"_".$rw['page'];
break;
事例“4”:
$URL="f"。$rw['fid']。"_".$rw['page']。"_".$rw['type'];
break;
}
}elseif(strpos($URL,'read.php?')!==false){
unset($rw);
$rarr=explode('&;'),substr(str_replace($add,'',$url),9));
foreach($rarras$key=>;$value){
$ru=explode('=',$value,2);
if($ru['1']){
switch($ru['0']){
case'tid':
$rw['tid']=$ru['1'];
$rw['type']<;1&&$rw['type']=1;
break;
case'page':
$rw['page']=$ru['1'];
$rw['type']<;2&&$rw['type']=2;
break;
case'fpage':
$rw['fpage']=$ru['1'];
$rw['type']<;3&&$rw['type']=3;
break;
默认值:
$rw['type']=4;
$URLfail=1;
break;
}
}
}
switch($rw['type']){
case'1':
$URL=$rw['tid']。".html";
break;
事例“2”:
$URL=$rw['tid']。"_".$rw['page']。".html";
break;
事例“3”:
$URL=$rw['tid']。"_".$rw['page']。"_".$rw['fpage']。".html";
break;
}
}
if($URLfail){
$URL=str_replace(
array('。'php?','=','&',$add),
array($db_dir,'-','-',''),
$url
)。$db_ext。$add
}
}elseif(strpos($URL,'hack.php?')!==false){
unset($rw);
$rarr=explode('&;'),substr(str_replace($add,'',$url),9));
foreach($rarras$key=>;$value){
$ru=explode('=',$value,2);
if($ru['1']){
switch($ru['0']){
case'H_name':
$rw['H_name_value']=$ru['1'];
if(in_array($rw['H_name_value'],array('fenlei','mm'){
$rw['type']=1;
}
break;
}
}
switch($rw['type']){
case'1':
$URL=$rw['H_name_value']。"/";
break;
//事例“2”:
//$URL=$rw['tid']。"_".$rw['page']。".html";
//break;
//事例“3”:
//$URL=$rw['tid']。"_".$rw['page']。"_".$rw['fpage']。".html";
//break;
}
}
}
return"$URL";
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)