芭奇软件站群技术交流反馈

 找回密码
 注册账号
搜索
查看: 5680|回复: 0

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

[复制链接]
bakii 发表于 lasttime | 显示全部楼层 |阅读模式
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/([a-z0-9\-]+\.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
然而有些朋友的discuz是装在windows下的虚拟主机上的,不过不要担心,很多 windows主机也是支持rewrite的。
问问你的主机提供商,如果支持的话,那么让客服把如下规则代码配置到你的虚拟主机上,你的discuz论坛就可以实现伪静态了

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

# 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 [L]
RewriteRule ^/home/(space|network)\.html$ /home/$1\.php [L]
RewriteRule ^/home/([0-9]+)$ /home/space\.php\?uid=$1 [L]

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

芭奇软件

GMT+8, 2024-4-24 11:03

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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