区块链 ·

phpwind高级教程: 高仿伪静态之高仿教程适用版本PW8(0913)

写在前面的话. 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
找到

复制代码

  1. function urlRewrite($url) {
  2. global $db_htmifopen, $db_dir, $db_ext;
  3. if (!$db_htmifopen) return $url;
  4. $tmppos = strpos($url, '#');
  5. $add = $tmppos !== false ? substr($url, $tmppos) : '';
  6. $turl = str_replace(array('.php?', '=', '&', '&', $add), array($db_dir, '-', '-', '-', ''), $url);
  7. $turl != $url && $turl .= $db_ext;
  8. return $turl . $add;
  9. }

替换成

复制代码

  1. function urlRewrite($url) {
  2. /*
  3. *本方法切勿三心二意,确保伪静态地址不会经常性更改,伪静态规则不会被扰乱,且仅适用在论坛中.
  4. *修改方法可以自由传播,如果你表明出处最好了! @By Josh( http://t.sina.com/abigbone ) 2010-7-30
  5. */
  6. global $db_htmifopen, $db_dir, $db_ext;
  7. if(strpos($url, 'thread.php?') !== false){
  8. unset($URL_type);
  9. $Thread_array = explode('&', substr(str_replace($add, '', $url), 11));
  10. foreach($Thread_array as $key => $value){
  11. $URL_array = explode('=', $value, 2);
  12. if($URL_array['1']){
  13. switch($URL_array['0']){
  14. case 'fid':
  15. $URL_type['fid'] = $URL_array['1'];
  16. $URL_type['type'] < 1 && $URL_type['type'] = 1;
  17. break;
  18. case 'page':
  19. $URL_type['page'] = $URL_array['1'];
  20. $URL_type['type'] < 2 && $URL_type['type'] = 2;
  21. break;
  22. default:
  23. $URL_type['type'] = 4;
  24. break;
  25. }}}
  26. switch($URL_type['type']){
  27. case '1':
  28. $url = "commtopics-" . $URL_type['fid'] ; break;
  29. case '2':
  30. $url = "commtopics-" . $URL_type['fid'] . "-" . $URL_type['page'] ;   break;
  31. }}elseif(strpos($url, 'read.php?') !== false){
  32. unset($URL_type);
  33. $tmppos = strpos($url, '#');
  34. $add = $tmppos !== false ? substr($url, $tmppos) : '';
  35. $Read_array = explode('&', substr(str_replace($add, '', $url), 9));
  36. foreach($Read_array as $key => $value){
  37. $URL_array = explode('=', $value, 2);
  38. if($URL_array['1']){
  39. switch($URL_array['0']){
  40. case 'tid':
  41. $URL_type['tid'] = $URL_array['1'];
  42. $URL_type['type'] < 1 && $URL_type['type'] = 1;
  43. break;
  44. case 'page':
  45. $URL_type['page'] = $URL_array['1'];
  46. $URL_type['type'] < 2 && $URL_type[type] = 2;
  47. break;
  48. case 'fpage':
  49. $URL_type['fpage'] = $URL_array['1'];
  50. $URL_type['type'] < 3 && $URL_type['type'] = 3;
  51. break;
  52. default:
  53. $URL_type['type'] = 4;
  54. break;
  55. }}}
  56. switch($URL_type['type']){
  57. case '1':
  58. $url = "article-".$URL_type['tid'].".html" ;
  59. break;
  60. case '2':
  61. $url = "article-".$URL_type['tid'] . "-" . $URL_type['page'].".html" ;
  62. break;
  63. case '3':
  64. $url = "article-". $URL_type['tid'] . "-" . $URL_type['page'] . "-" . $URL_type['fpage'].".html" ;
  65. break;
  66. }
  67. }
  68. //      $url .= $db_ext;  很多人以为后缀问题,故作特处理。
  69. return $url . $add;
  70. }

规则如下.  添加到httpd.ini或者.htaccess 或者其他

复制代码

  1. <IfModule mod_rewrite.c>
  2. RewriteEngine on
  3. RewriteRule ^thread-htm-tid-(\d+)-(.*).html  thread.php?fid=$1
  4. RewriteRule ^read-htm-tid-(\d+)-(.*).html  read.php?tid=$1
  5. RewriteRule ^commtopics-(\d+)-(.*)  thread.php?fid=$1&page=$2
  6. RewriteRule ^commtopics-(.*)       thread.php?fid=$1&page=$2
  7. RewriteRule ^article-(\d+)-(\d+)-(.*).html  read.php?tid=$1&page=$2&fpage=$3
  8. RewriteRule ^article-(\d+)-(\d+).html       read.php?tid=$1&page=$2
  9. RewriteRule ^article-(.*).html             read.php?tid=$1
  10. RewriteRule ^(.*)-htm-(.*).html    $1.php?$2
  11. RewriteRule ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2
  12. </IfModule>

参与评论