PHPwind高级伪静态规则及教程
写在前面的话. PW8 是个里程碑式的版本,有门户,有频道,等多元素多模式组成, stwind高度伪静态(超级伪静态)的处理方法仅仅适用于论坛部分. 并尽力避免与其他操作和地址产生冲突.在这个版本, 改变了几个变量,一个是列表页的变量,一个是过滤特殊字符的变量, 地址组成依然不变, 帖子也依然以 article 为前缀, 列表页以commtopics 链接.pw8里函数改动较大,所以修改也较为麻烦. 考虑到会被任意修改,以后版本考虑单个加密这个文件. 本次依然沿用以前的风格.
一,打开require/common.php
找到
function urlRewrite($url) {
global $db_htmifopen, $db_dir, $db_ext;
if (!$db_htmifopen) return $url;
$tmppos = strpos($url, '#');
$add = $tmppos !== false ? substr($url, $tmppos) : '';
$turl = str_replace(array('.php?', '=', '&', '&', $add), array($db_dir, '-', '-', '-', ''), $url);
$turl != $url && $turl .= $db_ext;
return $turl . $add;
}
替换成
function urlRewrite($url) {
global $db_htmifopen, $db_dir, $db_ext;
if(strpos($url, 'thread.php?') !== false){
unset($URL_type);
$Thread_array = explode('&', substr(str_replace($add, '', $url), 11));
foreach($Thread_array as $key => $value){
$URL_array = explode('=', $value, 2);
if($URL_array['1']){
switch($URL_array['0']){
case 'fid':
$URL_type['fid'] = $URL_array['1'];
$URL_type['type'] < 1 && $URL_type['type'] = 1;
break;
case 'page':
$URL_type['page'] = $URL_array['1'];
$URL_type['type'] < 2 && $URL_type['type'] = 2;
break;
default:
$URL_type['type'] = 4;
break;
}}}
switch($URL_type['type']){
case '1':
$url = "commtopics-" . $URL_type['fid'] ; break;
case '2':
$url = "commtopics-" . $URL_type['fid'] . "-" . $URL_type['page'] ; break;
}}elseif(strpos($url, 'read.php?') !== false){
unset($URL_type);
$tmppos = strpos($url, '#');
$add = $tmppos !== false ? substr($url, $tmppos) : '';
$Read_array = explode('&', substr(str_replace($add, '', $url), 9));
foreach($Read_array as $key => $value){
$URL_array = explode('=', $value, 2);
if($URL_array['1']){
switch($URL_array['0']){
case 'tid':
$URL_type['tid'] = $URL_array['1'];
$URL_type['type'] < 1 && $URL_type['type'] = 1;
break;
case 'page':
$URL_type['page'] = $URL_array['1'];
$URL_type['type'] < 2 && $URL_type[type] = 2;
break;
case 'fpage':
$URL_type['fpage'] = $URL_array['1'];
$URL_type['type'] < 3 && $URL_type['type'] = 3;
break;
default:
$URL_type['type'] = 4;
break;
}}}
switch($URL_type['type']){
case '1':
$url = "article-".$URL_type['tid'].".html" ;
break;
case '2':
$url = "article-".$URL_type['tid'] . "-" . $URL_type['page'].".html" ;
break;
case '3':
$url = "article-". $URL_type['tid'] . "-" . $URL_type['page'] . "-" . $URL_type['fpage'].".html" ;
break;
}
}
// $url .= $db_ext; 很多人以为后缀问题,故作特处理。
return $url . $add;
}
规则如下. 添加到httpd.ini或者.htaccess 或者其他
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^thread-htm-tid-(\d+)-(.*).html thread.php?fid=$1
RewriteRule ^read-htm-tid-(\d+)-(.*).html read.php?tid=$1
RewriteRule ^commtopics-(\d+)-(.*) thread.php?fid=$1&page=$2
RewriteRule ^commtopics-(.*) thread.php?fid=$1&page=$2
RewriteRule ^article-(\d+)-(\d+)-(.*).html read.php?tid=$1&page=$2&fpage=$3
RewriteRule ^article-(\d+)-(\d+).html read.php?tid=$1&page=$2
RewriteRule ^article-(.*).html read.php?tid=$1
RewriteRule ^(.*)-htm-(.*).html $1.php?$2
RewriteRule ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2
</IfModule>
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341