Entries Tagged as 'mod_rewrite'

discuz6.0后台开启“静态化”后页面出404的错误

朋友装了个discuz6.0
系统是linux+httpd2.2+mod_rewrite
一开启页面静态化
页面都变成404找不到了
然后去官网看了看
知道是没有rewrite规则
于是在discuz的目录下touch了一个.htaccess
在里面加上:

# 将 RewriteEngine 模式打开
RewriteEngine On

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

# 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

这里没啥可说的,唯一要注意的是RewriteBase
如果你的discuz是http://xxx.xxx.xx.xxx/discuz这样来访问的话
这里应该设成discuz
如果是http://xxx.xxx.xxx.xxx/这样的话
就应该设成/

.htaccess的方法是最灵活的解决方法
但是你需要先确认系统支持在.htaccess里写这些rewrite规则
(缺省一般是不让的)
于是还要在apache的配置文件里加上

<Directory /path/todiscuz>
AllowOverride Fileinfo
</Directory>

重写规则之类的语句只需要Fileinfo即可
然后重起apache
再起用静态化
就OK了

pre-compress static content in apache2.x by using mod_header + mod_rewrite

以下内容放到httpd.conf文件的合适位置

RewriteEngine on
RewriteLog “logs/modrewrite.log”
RewriteLogLevel 9
# If client accepts compressed files
RewriteCond %{HTTP:Accept-Encoding} gzip
# and if compressed file exists
RewriteCond %{DOCUMENT_ROOT}%{SCRIPT_FILENAME}.gz -f
# send .html.gz instead of .html
RewriteRule ^(.+)\.(html|xml|css)$ $1.$2.gz [T=text/$2,E=GZIP:gzip,L]
# notice: the line above is used in httpd 2.2.x, not in the httpd2.0.x
# RewriteRule ^(.+\.xml)$ $1.gz [T=text/xml,E=GZIP:gzip,L]
# RewriteRule ^(.+\.css)$ $1.gz [T=text/css,E=GZIP:gzip,L]
# RewriteRule ^(.+\.js)$ $1.gz [T=application/x-javascript,E=GZIP:gzip,L]
Header set Content-Encoding gzip env=GZIP