bakii 发表于 2010-9-12 19:37:00

discuz7.2伪静态浅析(.htaccess /httpd.ini)

discuz7.2伪静态浅析(.htaccess /httpd.ini)

今天终于能把论坛静态化了
首先说明一下你要知道你的主机是liniux或者Unix主机,还是windows下的虚拟主机。这两个是不一样的,前者.htaccess,后者httpd.ini。
discuz论坛系统的伪静态功能能够增强对搜索引擎的友好,让收录更加有优势。
discuz实现伪静态需要主机支持rewrite。在liniux或者Unix主机下discuz实现伪静态需要配置网站根目录下的.htaccess;

建立一个.htaccess,内容如下,发到你的根目录下就行了。
# 将 RewriteEngine 模式打开
RewriteEngine On
# 修改以下语句中的 /bbs 为你的论坛目录地址,如果论坛程序放在根目录中,请将 /bbs 修改为 /
RewriteBase /bbs
# Rewrite 系统规则请勿修改
RewriteRule ^archiver/(+\.html)$ archiver/index.php?$1
RewriteRule ^forum-(+)-(+)\.html$ forumdisplay.php?fid=$1&page=$2
RewriteRule ^thread-(+)-(+)-(+)\.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
然而有些朋友的discuz是装在windows下的虚拟主机上的,不过不要担心,很多 windows主机也是支持rewrite的。
问问你的主机提供商,如果支持的话,那么让客服把如下规则代码配置到你的虚拟主机上,你的discuz论坛就可以实现伪静态了

建一个httpd.ini文档,内容如下,发到你的根目录下就行了。


# 3600 = 1 hour
CacheClockRate 3600

RepeatLimit 32

# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
RewriteRule ^/home/(space|network)-(.+)\.html$ /home/$1\.php\?rewrite=$2
RewriteRule ^/home/(space|network)\.html$ /home/$1\.php
RewriteRule ^/home/(+)$ /home/space\.php\?uid=$1

RewriteRule ^(.*)/archiver/((fid|tid)-[\w\-]+\.html)\?*(.*)$ $1/archiver/index\.php\?$2&$4
RewriteRule ^(.*)/forum-(+)-(+)\.html\?*(.*)$ $1/forumdisplay\.php\?fid=$2&page=$3&$4
RewriteRule ^(.*)/thread-(+)-(+)-(+)\.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
页: [1]
查看完整版本: discuz7.2伪静态浅析(.htaccess /httpd.ini)