一聚教程网:一个值得你收藏的教程网站

热门教程

discuz URL 静态化

时间:2022-07-02 10:44:41 编辑:袖梨 来源:一聚教程网

discuz URL 静态化, discuz 静态化 ,discuz论坛静态化以及discuz 静态化设置 等下面我们一一列出静态化方法.

一、Apache Web Server(独立主机用户)

首先确定您使用的 Apache 版本,还有是否加载了 mod_rewrite 模块。

Apache 1.x 的用户请检查 conf/httpd.conf 中是否存在如下两段代码:

  LoadModule rewrite_module     libexec/mod_rewrite.so
AddModule mod_rewrite.c
Apache 2.x 的用户请检查 conf/httpd.conf 中是否存在如下一段代码

 LoadModule rewrite_module     modules/mod_rewrite.so

如果存在,那么在配置文件(通常就是 conf/httpd.conf)中加入如下代码。此时请务必注意,如果网站使用通过虚拟主机来定义,请务必加到虚拟主机配置,即中去,如果加在虚拟主机配置外部将可能无法使用。改好后将 Apache 重启。


       RewriteEngine On
       RewriteRule ^(.*)/archiver/((fid|tid)-[w-]+.html)$ $1/archiver/index.php?$2
       RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+).html$ $1/forumdisplay.php?fid=$2&page=$3
       RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=$3
       RewriteRule ^(.*)/space-(username|uid)-(.+).html$ $1/space.php?$2=$3
       RewriteRule ^(.*)/tag-(.+).html$ $1/tag.php?name=$2

二、Apache Web Server(虚拟主机用户)

在开始以下设置之前,请首先咨询您的空间服务商,空间是否支持 Rewrite 以及是否支持对站点目录中 .htaccess 的文件解析,否则即便按照下面的方法设置好了,也无法使用。

检查论坛所在目录中是否存在 .htaccess 文件,如果不存在,请手工建立此文件。Win32 系统下,无法直接建立 .htaccess 文件,您可以从其他系统中拷贝一份,或者在 Discuz.net 技术支持栏目中下载此文件。编辑并修改 .htaccess 文件,添加以下内容

# 将 RewriteEngine 模式打开
RewriteEngine On

# 修改以下语句中的 /discuz 为你的论坛目录地址,如果程序放在根目录中,请将 /discuz 修改为 /
RewriteBase /discuz

# Rewrite 系统规则请勿修改
RewriteRule ^archiver/((fid|tid)-[w-]+.html)$ archiver/index.php?$1
RewriteRule ^forum-([0-9]+)-([0-9]+).html$ forumdisplay.php?fid=$1&page=$2
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+).html$ viewthread.php?tid=$1&extra=page%3D$3&page=$2
RewriteRule ^space-(username|uid)-(.+).html$ space.php?$1=$2
RewriteRule ^tag-(.+).html$ tag.php?name=$1

 

IIS Web Server(独立主机用户)

首先在 IIS 的 Isapi 上添加这个筛选器,筛选器名称为 Rewrite ,可执行文件选择 Rewrite.dll ,重新启动 IIS。附件中 httpd.ini 已经设置好,其中内容如下:

# 3600 = 1 hour
CacheClockRate 3600

RepeatLimit 32

# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
RewriteRule ^(.*)/archiver/((fid|tid)-[w-]+.html)?*(.*)$ $1/archiver/index.php?$2&$4
RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+).html?*(.*)$ $1/forumdisplay.php?fid=$2&page=$3&$4
RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html?*(.*)$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=$3&$4
RewriteRule ^(.*)/space-(username|uid)-(.+).html?*(.*)$ $1/space.php?$2=$3&$4
RewriteRule ^(.*)/tag-(.+).html?*(.*)$ $1/tag.php?name=$2&$3

四、Zeus Web Server

在虚拟主机配置中找到 Request Rewriting,在 Rewrite Script 中写入以下内容,然后 Apply changes 并 make it take effect。

match URL into $ with ^(.*)/archiver/((fid|tid)-[w-]+.html)?*(.*)$
       if matched then
        set URL = $1/archiver/index.php?$2&$4
       endif
       match URL into $ with ^(.*)/forum-([0-9]+)-([0-9]+).html?*(.*)$
       if matched then
        set URL = $1/forumdisplay.php?fid=$2&page=$3&$4
       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&$4
       endif
       match URL into $ with ^(.*)/space-(username|uid)-(.+?).html?*(.*)$
       if matched then
        set URL = $1/space.php?$2=$3&$4
       endif
       match URL into $ with ^(.*)/tag-(.+?).html?*(.*)$
       if matched then
        set URL = $1/tag.php?name=$2$3
       endif

 

热门栏目