zzydlqs 发表于 2009-8-1 11:10:53

discuz7 静态化网页生成

1配置Apache服务器支持.htaccess       这是独立主机配置(不需要在论坛目录下放置.htaccess文件),虚拟机让空间商配置。
1、让Apache支持mod_rewrite重写,打开Apache配置文件httpd.conf,查找并去掉下行前面的#号
   LoadModule rewrite_module modules/mod_rewrite.so
如果不加载以下代码,则需要把.htaccess文件放置到论坛目录
<IfModule mod_rewrite.c>
                RewriteEngine On
                RewriteRule ^(.*)/archiver/((fid|tid)-+\.html)$ $1/archiver/index.php?$2
                RewriteRule ^(.*)/forum-(+)-(+)\.html$ $1/forumdisplay.php?fid=$2&page=$3
                RewriteRule ^(.*)/thread-(+)-(+)-(+)\.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
      </IfModule>
2、让Apache支持.htaccess,打开Apache虚拟主机配置文件/conf/extra/httpd-vhosts.conf,查找并更改配置如下:
    <Directory "E:/www/Souxiu">
    Options FollowSymLinks IncludesNOEXEC
    DirectoryIndex default.html default.php
    AllowOverride All //默认为None
    Order Deny,Allow
    Allow from all
    </Directory>
    AddDefaultCharset off //解决Apache中文乱码,关闭服务器的默认语言的发送,凭html文件头中设置的语言来决定网页语言。
注以下是:首页静态化规则
RewriteRule ^(.*)/index\.html$ $1/index.php
RewriteRule ^(.*)/index-(+)\.html$ $1/index.php?gid=$2
以上两行代码,加载后,网站index.html不能打开.修改网站首页文件名为default.html,并修改apache配置文件httpd.conf中的directoryIndexindex.htmlindex.php 为    directoryIndexindex.htmlindex.php default.html。重启apache 即可。
2、虚拟主机则把下面代码另存为.htaccess
# 将 RewriteEngine 模式打开
RewriteEngine On

RewriteBase /bbs

# Rewrite 系统规则请勿修改
RewriteRule ^archiver/((fid|tid)-[\w\-]+\.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
注意:修改RewriteBase /bbs为你的论坛目录

3、上传附件到论坛目录

网站首页index.html与discuz论坛首页静态化后的index.html,有冲突。就是不能同时打开。修改网站首页后为default.html并修改apache配置文件增加default.html的支持后,最终解决。现在可以访问网站首页www.xwzjw.cn/default.html和论坛首页www.xwzjw.cn/bbs/index.html
页: [1]
查看完整版本: discuz7 静态化网页生成