PHPwind 伪静态简化URL长度为1.html,f2等的方法介绍
1。根目录下.htaccess(规则适用iis,其他nginx、apache还要稍做修改)
RewriteEngine on
RewriteRule f(\d+)_(.*)_(.*)$ /thread.php?fid=$1&page=$2&type=$3 [L]
RewriteRule f(\d+)_(.*)$ /thread.php?fid=$1&page=$2 [L]
RewriteRule f(\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?tid=$1 [L]
RewriteRule ^(.*)-htm-(.*)$ $1.php?$2 [L]
RewriteRule /simple/([a-z0-9\_]+)\.html$ /simple/index\.php\?$1 [L]
2、在require/common.php
找到
function urlRewrite($url) {
换成:
function urlRewrite($url) {
global $db_htmifopen, $db_dir, $db_ext;
if (!$db_htmifopen) return $url;
if (!preg_match('/^(http|ftp|telnet|mms|rtsp)|admin.php|rss.php/i', $url)){
$add = strpos($url, '#') !== false ? substr($url, strpos($url, '#')) : '';
if(strpos($url, 'thread.php?') !== false){
unset($rw);
$tharr = explode('&', substr(str_replace($add, '', $url), 11));
foreach($tharr as $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;
default:
$rw['para'] = 8;
$urlfail = 1;
break;
}
}
}
switch($rw['para']){
case '1':
$url = "f" . $rw['fid'] ;
break;
case '2':
$url = "f" . $rw['fid'] . "_" . $rw['page'] ;
break;
case '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($rarr as $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;
default:
$rw['type'] = 4;
$urlfail = 1;
break;
}
}
}
switch($rw['type']){
case '1':
$url = $rw['tid'] . ".html";
break;
case '2':
$url = $rw['tid'] . "_" . $rw['page'] . ".html";
break;
case '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($rarr as $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;
//case '2':
// $url = $rw['tid'] . "_" . $rw['page'] . ".html";
// break;
//case '3':
// $url = $rw['tid'] . "_" . $rw['page'] . "_" . $rw['fpage'] . ".html";
// break;
}
}
}
return "$url";
}
栏 目:phpcms
本文标题:PHPwind 伪静态简化URL长度为1.html,f2等的方法介绍
本文地址:https://www.xiuzhanwang.com/a1/phpcms/9904.html
您可能感兴趣的文章
阅读排行
本栏相关
- 01-10phpcms常见问题解答
- 01-10phpcms语法规则
- 01-10PHPCMS2008 SP4 心情排行指数不显示的解
- 01-10PHPCMS网站转移空间教程
- 01-10PHPCMS系统自带标签说明
- 01-10phpcms标签模板及专题模板的制作
- 01-10phpcms频道首页调用所有一级栏目及二
- 01-10PHPcms 2008 注册选择模型关闭后,注册
- 01-10为PHPCMS 2008 编辑器增加常用中文字体
- 01-10phpcms模仿QQ和MSN消息提示的效果
随机阅读
- 04-02jquery与jsp,用jquery
- 08-05DEDE织梦data目录下的sessions文件夹有什
- 01-11ajax实现页面的局部加载
- 01-10SublimeText编译C开发环境设置
- 08-05dedecms(织梦)副栏目数量限制代码修改
- 08-05织梦dedecms什么时候用栏目交叉功能?
- 01-10delphi制作wav文件的方法
- 01-10C#中split用法实例总结
- 01-11Mac OSX 打开原生自带读写NTFS功能(图文
- 01-10使用C语言求解扑克牌的顺子及n个骰子