写在前面的话. PW8 是个里程碑式的版本,有门户,有频道,等多元素多模式组成, stwind高度伪静态(超级伪静态)的处理方法仅仅适用于论坛部分. 并尽力避免与其他操作和地址产生冲突.在这个版本, 改变了几个变量,一个是列表页的变量,一个是过滤特殊字符的变量, 地址组成依然不变, 帖子也依然以 article 为前缀, 列表页以commtopics 链接.pw8里函数改动较大,所以修改也较为麻烦. 考虑到会被任意修改,以后版本考虑单个加密这个文件. 本次依然沿用以前的风格. 先给修改方法,再给懒人包.
引用
0824 更新了: 覆盖0810程序文件后找不到修改文件,无法使用问题
0803 更新了: 规则里添加了一条, 解决帖子页面不能翻页问题~~
STWind伪静态之高仿教程适用版本7.5(x)[1223更新] :http://www.phpwind.net/read-htm-tid-894423.html
/*
*本方法切勿三心二意,确保伪静态地址不会经常性更改,伪静态规则不会被扰乱,且仅适用在论坛中.
*修改方法可以自由传播,如果你表明出处最好了! @By Josh(http://t.sina.com/abigbone) 2010-8-24
*/
一,打开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) {
- /*
- *本方法切勿三心二意,确保伪静态地址不会经常性更改,伪静态规则不会被扰乱,且仅适用在论坛中.
- *修改方法可以自由传播,如果你表明出处最好了! @By Josh( http://t.sina.com/abigbone ) 2010-7-30
- */
- 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>
|