Discuz!官方免费开源建站系统

 找回密码
 立即注册
搜索

[经验] PW论坛转换成DZ论坛后的原静态URL失效问题完美解决方案

[复制链接]
stanley 发表于 2006-12-19 18:00:06 | 显示全部楼层 |阅读模式
很多的朋友的PW论坛伪静态化之后,论坛地址全部变成:
read-htm-??.html
thread-htm-???.html
转换到DZ论坛后势必会流失大量的搜索引擎过来的URL,如何让它继续有效呢?

经过两天的测试和摸索,终于把这个问题解决掉了

1、在http.conf有关虚拟主机的        <IfModule mod_rewrite.c></IfModule>之间加上以下代码



  1.                 RewriteRule ^(.*)/archiver/([a-z0-9\-]+\.html)$ $1/archiver/index.php?$2
  2.                 RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&page=$3
  3.                 RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&extra=page\%3D$4&page=$3
  4.                 RewriteRule ^(.*)/profile-(username|uid)-(.+)\.html$ $1/viewpro.php?$2=$3
  5.                 RewriteRule ^/thread-htm-fid-([0-9]+)(.*)\.html$ /forumdisplay.php?fid=$1 [L,R]
  6.                 RewriteRule ^/thread.php(.*)$ /forumdisplay.php$1 [L,R]
  7.                 RewriteRule ^/read-htm-tid-([0-9]+)(.*)\.html$ /viewthread.php?tid=$1 [L,R]
  8.                 RewriteRule ^/read.php(.*)$ /viewthread.php$1 [L,R]
  9.                 RewriteRule ^/home.php$ /index.php [L,R]
  10.                 RewriteRule ^/simple/ /archiver/ [R]
  11.                 RewriteRule ^/notice.php /announcement.php [R]
  12.                 RewriteRule ^/notice-htm-(.*)\.html /announcement.php [R]
  13.                 RewriteRule ^/job-htm-(.*)\.html /index.php [R]
  14.                 RewriteRule ^/job.php /index.php [R]
  15.                 RewriteRule ^/bt.php /forumdisplay.php?fid=99 [R]
  16.                 RewriteRule ^/bt-htm-(.*)\.html /forumdisplay.php?fid=99 [R]
复制代码

2、在archiver/index.php

里找到
  1. if($tid) {
  2.         $action = 'thread';
  3.         $forward = 'viewthread.php?tid='.$tid;
  4. } elseif($fid) {
  5.         $action = 'forum';
  6.         $forward = 'forumdisplay.php?fid='.$fid;
  7. } else {
  8.         $action = 'index';
  9.         $forward = 'index.php';
  10. }
复制代码

在它之前加上

  1. $R_URL=substr(($cutchar=strrchr($REQUEST_URI,'?')) ? substr($cutchar,1) :'',0,-5);

  2. if($R_URL){
  3.         $R_URL_A=explode('_',$R_URL);
  4.         $prog=substr($R_URL_A[0],0,1);
  5.         $id=(int)substr($R_URL_A[0],1);
  6.         $page=(int)$R_URL_A[1];
  7. }else{
  8.         $prog='';
  9. }

  10. switch($prog){
  11.         case 'f':
  12.                 $fid =& $id;break;
  13. //                include_once(R_P.'simple/mod_thread.php');
  14.         case 't':
  15.                 $tid =& $id;break;
  16. //                include_once(R_P.'simple/mod_read.php');
  17.         default:
  18. //                include_once(R_P.'simple/mod_index.php');
  19. }
复制代码

不过这时一定要启用Achiver静态化,不然Achiver就没用了
基本上就可以了,

[ 本帖最后由 stanley 于 2006-12-21 10:26 编辑 ]

评分

1

查看全部评分

回复

使用道具 举报

 楼主| stanley 发表于 2006-12-19 18:01:06 | 显示全部楼层
昨天、前天还在求助呢,求人不如求已啊,还长了大量的知识

建议加精
回复

使用道具 举报

 楼主| stanley 发表于 2006-12-20 10:17:59 | 显示全部楼层
修改了一下,希望对大家有用
回复

使用道具 举报

zw80 发表于 2006-12-20 13:46:20 | 显示全部楼层

附上ZEUS的

match URL into $ with ^(.*)/read-html-tid-(.*)$
if matched then
set URL = $1/viewthread.php?tid=$2
endif
match URL into $ with ^(.*)/thread-html-fid-(.*)$
if matched then
set URL = $1/forumdisplay.php?fid=$2
endif
match URL into $ with ^(.*)/simple/f(.*)$
if matched then
set URL = $1/archiver/index.php?fid-$2
endif
match URL into $ with ^(.*)/simple/t(.*)$
if matched then
set URL = $1/archiver/index.php?tid-$2
endif
match URL into $ with ^(.*)/simple/index.php\?f(.*)$
if matched then
set URL = $1/archiver/index.php?fid-$2
endif
match URL into $ with ^(.*)/simple/index.php\?t(.*)$
if matched then
set URL = $1/archiver/index.php?tid-$2
endif
match URL into $ with ^(.*)/archiver/([a-z0-9\-]+\.html)$
if matched then
set URL = $1/archiver/index.php?$2
endif
match URL into $ with ^(.*)/forum-([0-9]+)-([0-9]+)\.html$
if matched then
set URL = $1/forumdisplay.php?fid=$2&page=$3
endif
match URL into $ with ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$
if matched then
set URL = $1/viewthread.php?tid=$2&extra=page\%3D$4&page=$3
endif
match URL into $ with ^(.*)/profile-(username|uid)-(.+?)\.html$
if matched then
set URL = $1/viewpro.php?$2=$3
endif

[ 本帖最后由 zw80 于 2006-12-20 13:47 编辑 ]
回复

使用道具 举报

方向的美 发表于 2006-12-20 14:19:48 | 显示全部楼层
谢谢分享,不错,支持
回复

使用道具 举报

 楼主| stanley 发表于 2006-12-21 10:24:03 | 显示全部楼层
加了几条,呵呵,这下就更少有失效的了
回复

使用道具 举报

008at 发表于 2006-12-21 10:42:52 | 显示全部楼层
帮顶。不错的代码。
回复

使用道具 举报

掠图大盗 发表于 2008-2-19 18:55:50 | 显示全部楼层
。。。。
回复

使用道具 举报

jtbnu 发表于 2008-2-20 09:27:49 | 显示全部楼层
支持一下
呵呵
回复

使用道具 举报

pu6371058 发表于 2008-6-28 16:29:14 | 显示全部楼层
(::35::) (::35::) (::35::) (::35::)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-9-12 22:15 , Processed in 0.113489 second(s), 15 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表