由于对现在的网站CMS程序不满意,准备更改网站程序,但现有的收录同时也想保持。现在的网站收录是http://www.startcn.net/viewnews-8120.html ,是用PHP伪静态生成的虚拟链接,也就是在根目录下并不存在/viewnews-8120.html 这个文件,现在我想让用户访问http://www.startcn.net/viewnews-8120.html 时自动转向到http://www.startcn.net/html/20/n-8120.html ,也就是说我要将这些链接指向到一个实际存在的静态文件上。
具体的文件命名方法是:取viewnews-8120.html 最后的数字2位,即20作为文件目录,并保存到html文件夹中,新的文件名是n-8120.html .
不知道要如何做。
有一种方法似乎可行,但太笨了。就是将模仿所有的伪静态链接都生成实际存在的静态链接文件,那样的话,就是在网站的根目录下要有10000多个文件,因为我的网站现在有10000多个记录。

解决方案 »

  1.   

    Web Server用的是IIS还是Apache?这两个都可以进行URL Rewrite的..
      

  2.   

    网站服务器是IIS的,现在用的规则是:
    RewriteRule ^/([0-9]+)$ /index\.php\?uid/$1 [L]
    RewriteRule ^/([0-9]+)/spacelist(.+)$ /index\.php\?uid/$1/action/spacelist/type$2 [L]
    RewriteRule ^/([0-9]+)/viewspace(.+)$ /index\.php\?uid/$1/action/viewspace/itemid$2 [L]
    RewriteRule ^/([0-9]+)/viewbbs(.+)$ /index\.php\?uid/$1/action/viewbbs/tid$2 [L]
    RewriteRule ^/([0-9]+)/(.*)$ /index\.php\?uid/$1/$2 [L]
    RewriteRule ^/action(.+)$ /index\.php\?action$1 [L]
    RewriteRule ^/category(.+)$ /index\.php\?action/category/catid$1 [L]
    RewriteRule ^/viewnews(.+)$ /index\.php\?action/viewnews/itemid$1 [L]
    RewriteRule ^/viewthread(.+)$ /index\.php\?action/viewthread/tid$1 [L]
    RewriteRule ^/mygroup(.+)$ /index\.php\?action/mygroup/gid$1 [L]
      

  3.   

    增加一句重写即可,不知道下面这句行不行。大概就这意思。RewriteRule ^html/([^0-9][^0-9][0-9][0-9])/n-([0-9]+).html$ viewnews-$1.html [NC,L]