You are here

[Discuz! X安装记录]设置URL静态化后404错误

置顶AD:国内怎么/如何用VPN代理软件翻墙上youtube.com看视频和facebook twitter等等...
付费VPN代理IP---号外 淘宝商城改名为天猫 快去看看吧

最近折腾一个discuz x

第一个问题:URL 静态化

在 全局-优化设置-URL 静态化 勾上几个选项后

打开论坛页面就报404错误了

Not Found
The requested URL /forum-2-1.html was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
搜索一下 原来 .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

保存后还是出问题,看了错误提示:

Not Found
The requested URL /forumdisplay.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

看了一下根目录下有个forum.php 没有forumdisplay.php文件,重新搜一个方法:

# 将 RewriteEngine 模式打开
 RewriteEngine On
 # 修改以下语句中的 /discuz 为你的论坛目录地址,如果程序放在根目录中,请将 /discuz 修改为 /
 RewriteBase /
 # Rewrite 系统规则请勿修改
 RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topic;=$1
 RewriteRule ^article-([0-9]+)\.html$ portal.php?mod=article&articleid;=$1
 RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid;=$1&page;=$2
 RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid;=$1&extra;=page\%3D$3&page;=$2
 RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid;=$1&page;=$2
RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2
RewriteRule ^([a-z]+)-(.+)\.html$ $1.php?rewrite=$2

终于搞定.

文章类型: