1.在后台“全局》SEO设置》URL 静态化”相关复选框全部勾选,点“提交”按钮。
2.下载附件.htaccess直接用FTP上传到论坛根目录即可,不要修改文件名,就是.htaccess
其他目录的话修改第2行“RewriteBase /discuz” 把discuz换成目录名,如在bbs目录则改为:RewriteBase /bbs .htaccess文件放在bbs目录
默认规则如下:
# 将以下内容保存为 .htaccess 文件
# 将 RewriteEngine 模式打开
RewriteEngine On
# 修改以下语句中的 /discuz 为您的论坛目录地址,如果程序放在根目录中,请将 /discuz 修改为 /
-
RewriteBase /
-
# Rewrite 系统规则请勿修改
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topic=$1&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\=$3&page=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ plugin.php?id=$1:$2&%1
Discuz! X2.5 Apache伪静态规则
默认规则如下:
-
RewriteEngine On
-
RewriteBase /discuz
-
# Rewrite 系统规则请勿修改
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topic=$1&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\=$3&page=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ plugin.php?id=$1:$2&%1
Discuz! X2.0 Apache伪静态规则
默认规则如下:
-
# 将 RewriteEngine 模式打开
-
RewriteEngine On
-
# 修改以下语句中的 /discuz 为你的论坛目录地址,如果程序放在根目录中,请将 /discuz 修改为 /
-
RewriteBase /discuz
-
# Rewrite 系统规则请勿修改
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\=$3&page=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
-
RewriteCond %{QUERY_STRING} ^(.*)$
-
RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
Discuz! X2 相对于 X15 来说,rewrite 做了一定的调整:
1. 后台位置变化:由 X15 的“全局 → 优化设置”,调整为 X2 的“全局 → SEO设置”
2. 数量变化:由 X15 的 6 项针对性设置 + 1 项全站动态页面,调整为 X2 的 8 项针对设置性
如果希望对之前的已经收录的rewrite仍可以访问,可以做如下兼容:
1. 修改 rewrite 规则:有两种方法可以使用
1) 将 X2 后台提供的 rewrtie 规则放在 X15 的规则的前面即可,任何规则都可以不删除
2) 将下面地址中的 rewrite 规则放在 X15 的规则的前面
http://www.discuz.net/thread-2109624-1-1.html
2. 修改文件:
找到:source/class/class_core.php 191行附近
-
function _init_input() {
-
if (isset($_GET['GLOBALS']) ||isset($_POST['GLOBALS']) || isset($_COOKIE['GLOBALS']) || isset($_FILES['GLOBALS'])) {
-
system_error('request_tainting');
-
}
-
if(!MAGIC_QUOTES_GPC) {
-
$_GET = daddslashes($_GET);
-
$_POST = daddslashes($_POST);
-
$_COOKIE = daddslashes($_COOKIE);
-
$_FILES = daddslashes($_FILES);
-
}
-
修改为下面的
-
function _init_input() {
-
if (isset($_GET['GLOBALS']) ||isset($_POST['GLOBALS']) || isset($_COOKIE['GLOBALS']) || isset($_FILES['GLOBALS'])) {
-
system_error('request_tainting');
-
}
-
if(!emptyempty($_GET['rewrite'])) {
-
$query_string = '?mod=';
-
$param = explode('-', $_GET['rewrite']);
-
$query_string .= $_GET['mod'] = $param[0];
-
array_shift($param);
-
$paramc = count($param);
-
for($i = 0;$i < $paramc;$i+=2) {
-
$_REQUEST[$param[$i]] = $_GET[$param[$i]] = $param[$i + 1];
-
$query_string .= '&'.$param[$i].'='.$param[$i + 1];
-
}
-
$_SERVER['QUERY_STRING'] = $query_string;
-
unset($param, $paramc, $query_string);
-
}
-
if(!MAGIC_QUOTES_GPC) {
-
$_GET = daddslashes($_GET);
-
$_POST = daddslashes($_POST);
-
$_COOKIE = daddslashes($_COOKIE);
-
$_FILES = daddslashes($_FILES);
-
}