主页 > 业界微闻 | 伪静态 > STWind 高级伪静态教程适用版本PW8.3(1208)

STWind 高级伪静态教程适用版本PW8.3(1208)

很久没有发帖,很久没有冒泡, 8.3给我带来的惊喜让很多朋友都着急升级,当然用着8.0 或者更早的版本不那么方便直接升级,今天抽空把代码移植下~对大家有用的话那最好了! 我查看了8.0 版本下载了700多次,这个下载数让我有点吃惊~~ ,我觉得有义务把这个方法延续做下去~~

8.0版本(0913):http://www.phpwind.net/read-htm-tid-1054381.html
7.5(x)[1223更新] :http://www.phpwind.net/read-htm-tid-894423.html

/*
*本方法切勿三心二意,确保伪静态地址不会经常性更改,伪静态规则不会被扰乱,且仅适用在论坛中.
*修改方法可以自由传播,如果你表明出处最好了! @某骨头 (http://t.sina.com/abigbone) 2010-12-08
*/
按照惯例,我们直接说如何修改,并在后面提供修改方法
一:打开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) {
/*
*本方法切勿三心二意,确保伪静态地址不会经常性更改,伪静态规则不会被扰乱,且仅适用在论坛中.
*修改方法可以自由传播,如果你表明出处最好了! @某骨头(http://t.sina.com/abigbone) 2010-12-08
*/
global $db_htmifopen, $db_dir, $db_ext;
if (!$db_htmifopen) return $url;
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;
}
}
return $url . $add;
}

规则如下.? 添加到httpd.ini或者.htaccess 或者其他<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} ^index.php.*
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+)-(.*).html?? ??? read.php?tid=$1&page=$2#a
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>
伪静态
如果您不熟悉编辑器,请用懒人包覆盖~~
下载:http://www.phpwind.net/read-htm-tid-1177416.html

, ,

发表评论

引用:0

下面所列的是引用到本博客的链接
STWind 高级伪静态教程适用版本PW8.3(1208) 来自 ANTeams Logs!
顶部