BMForum Rewrite设置

来自站长百科
跳转至: 导航、​ 搜索

导航: 上一页

BMForum支持利用 Apache Rewrite 模块,将论坛的页面输出为 HTML,大幅度提高搜索引擎的收录。

启用方法[ ]

1. 确保您的服务器支持 Rewrite (一般情况下, Apache, Zeus 都可以支持)。如果服务器是 IIS,需要使用相关插件来实现(不推荐)

Apache Web Server[ ]

论坛所在目录上传名为 “.htaccess”的文件(不包括引号),内容为:

{| style='border:1px solid #AAAAAA;background-color:#F9F9F9' width=90% align=left
|<IfModule mod_rewrite.c>
RewriteEngine on

RewriteBase /bbs/

RewriteRule ^index.html$ index.php

RewriteRule ^forums_([0-9]+).html$ forums.php?forumid=$1

RewriteRule ^forums_([0-9]+)_([0-9]+).html$ forums.php?forumid=$1&page=$2

RewriteRule ^forums_([0-9]+)_([0-9]+)_([a-zA-Z0-9]*)_([a-zA-Z]*)_([a-zA-Z]*).html$ forums.php?forumid=$1&page=$2&jinhua=$3&listby=$4&trash=$5

RewriteRule ^topic_([0-9]+).html$ topic.php?filename=$1

RewriteRule ^topic_([0-9]+)_([a-zA-Z0-9]*).html$ topic.php?filename=$1&page=$2

RewriteRule ^forums_([0-9]+)$ forums.php?forumid=$1 

RewriteRule ^forums_([0-9]+)_([0-9]+)$ forums.php?forumid=$1&page=$2 

RewriteRule ^forums_([0-9]+)_([0-9]+)_([a-zA-Z0-9]*)_([a-zA-Z]*)_([a-zA-Z]*)$ forums.php?forumid=$1&page=$2&jinhua=$3&listby=$4&trash=$5 

RewriteRule ^topic_([0-9]+)$ topic.php?filename=$1 

RewriteRule ^topic_([0-9]+)_([a-zA-Z0-9]*)$ topic.php?filename=$1&page=$2 

</IfModule>

|}

ISAPI Rewrite[ ]

将以下内容保存为 httpd.ini 放置于网站根目录下(部分虚拟主机需要联系管理员修改)

{| style='border:1px solid #AAAAAA;background-color:#F9F9F9' width=90% align=left
|[ISAPI_Rewrite] 
CacheClockRate 3600 

RepeatLimit 32 

UriMatchPrefix \/bbs\/

UriFormatPrefix \/bbs\/ 

RewriteRule forums_([0-9]+).html$ forums.php\?forumid=$1 

RewriteRule forums_([0-9]+)_([0-9]+).html$ forums.php\?forumid=$1&page=$2 

RewriteRule forums_([0-9]+)_([0-9]+)_([a-zA-Z0-9]*)_([a-zA-Z]*)_([a-zA-Z]*).html$ forums.php\?forumid=$1&page=$2&jinhua=$3&listby=$4&trash=$5 

RewriteRule topic_([0-9]+).html$ topic.php\?filename=$1 

RewriteRule topic_([0-9]+)_([a-zA-Z0-9]*).html$ topic.php\?filename=$1&page=$2 

RewriteRule forums_([0-9]+)$ forums.php\?forumid=$1 

RewriteRule forums_([0-9]+)_([0-9]+)$ forums.php\?forumid=$1&page=$2 

RewriteRule forums_([0-9]+)_([0-9]+)_([a-zA-Z0-9]*)_([a-zA-Z]*)_([a-zA-Z]*)$ forums.php\?forumid=$1&page=$2&jinhua=$3&listby=$4&trash=$5 

RewriteRule topic_([0-9]+)$ topic.php\?filename=$1 

RewriteRule topic_([0-9]+)_([a-zA-Z0-9]*)$ topic.php\?filename=$1&page=$2 

|}

Zeus Web Server[ ]

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

{| style='border:1px solid #AAAAAA;background-color:#F9F9F9' width=90% align=left
|
match URL into $ with ^(.*)/forums_([0-9]+)\.html$

if matched then

	set URL = $1/forums.php?forumid=$2

endif

match URL into $ with ^(.*)/forums_([0-9]+)_([0-9]+)_([a-zA-Z0-9]*)_([a-zA-Z]*)_([a-zA-Z]*)\.html$

if matched then

	set URL = $1/forums.php?forumid=$2&page=$3&jinhua=$4&listby=$5&trash=$6

endif

match URL into $ with ^(.*)/forums_([0-9]+)_([0-9]+)\.html$

if matched then

	set URL = $1/forums.php?forumid=$2&page=$3

endif

match URL into $ with ^(.*)/topic-([0-9]+)\.html$

if matched then

	set URL = $1/topic.php?filename=$2

endif

match URL into $ with ^(.*)/topic_([0-9]+)_([a-zA-Z0-9]*)\.html$

if matched then

	set URL = $1/topic.php?filename=$2&page=$3

endif

match URL into $ with ^(.*)/forums_([0-9]+)\$

if matched then

	set URL = $1/forums.php?forumid=$2

endif

match URL into $ with ^(.*)/forums_([0-9]+)_([0-9]+)_([a-zA-Z0-9]*)_([a-zA-Z]*)_([a-zA-Z]*)\$

if matched then

	set URL = $1/forums.php?forumid=$2&page=$3&jinhua=$4&listby=$5&trash=$6

endif

match URL into $ with ^(.*)/forums_([0-9]+)_([0-9]+)\$

if matched then

	set URL = $1/forums.php?forumid=$2&page=$3

endif

match URL into $ with ^(.*)/topic-([0-9]+)\$

if matched then

	set URL = $1/topic.php?filename=$2

endif

match URL into $ with ^(.*)/topic_([0-9]+)_([a-zA-Z0-9]*)\$

if matched then

	set URL = $1/topic.php?filename=$2&page=$3

endif


|}

注意,请将所有的 /bbs/ 替换为论坛所在路径,例如:

http://www.hellobmf.com/forum/ 的路径则为 /forum/

http://bbs.hellobmf.com/ 的路径则为 /

注:ISAPI Rewrite 中需要替换 \/bbs\/ 为论坛所在路径,例如:

http://www.hellobmf.com/forum/ 的路径则为 \/forum\/

http://bbs.hellobmf.com/ 的路径则为 \/


3. 进入论坛管理中心,设置常规选项,将 采用 Rewrite 伪装 HTML 页面 选项打开

相关条目[ ]

参考来源[ ]