|
|
File need to edit: source/function/function_core.php
- function rewriteoutput($type, $returntype, $host) {
- global $_G;
- $fextra = '';
- if($type == 'forum_forumdisplay') {
- [, , , $fid, $page, $extra] = func_get_args();
- $r = [
- '{fid}' => empty($_G['setting']['forumkeys'][$fid]) ? $fid : $_G['setting']['forumkeys'][$fid],
- '{page}' => $page ? $page : 1,
- ];
- } elseif($type == 'forum_viewthread') {
- [, , , $tid, $page, $prevpage, $extra] = func_get_args();
- $r = [
- '{tid}' => $tid,
- '{page}' => $page ? $page : 1,
- '{prevpage}' => $prevpage && !IS_ROBOT ? $prevpage : 1,
- ];
- } elseif($type == 'home_space') {
- [, , , $uid, $username, $extra] = func_get_args();
- $_G['setting']['rewritecompatible'] && $username = rawurlencode($username);
- $r = [
- '{user}' => $uid ? 'uid' : 'username',
- '{value}' => $uid ? $uid : $username,
- ];
- } elseif($type == 'home_blog') {
- [, , , $uid, $blogid, $extra] = func_get_args();
- $r = [
- '{uid}' => $uid,
- '{blogid}' => $blogid,
- ];
- } elseif($type == 'group_group') {
- [, , , $fid, $page, $extra] = func_get_args();
- $r = [
- '{fid}' => $fid,
- '{page}' => $page ? $page : 1,
- ];
- } elseif($type == 'portal_topic') {
- [, , , $name, $extra] = func_get_args();
- $r = [
- '{name}' => $name,
- ];
- } elseif($type == 'portal_article') {
- [, , , $id, $page, $extra] = func_get_args();
- $r = [
- '{id}' => $id,
- '{page}' => $page ? $page : 1,
- ];
- } elseif($type == 'forum_archiver') {
- [, , $action, $value, $page, $extra] = func_get_args();
- $host = '';
- $r = [
- '{action}' => $action,
- '{value}' => $value,
- ];
- if($page) {
- $fextra = '?page='.$page;
- }
- } elseif($type == 'plugin') {
- [, , $pluginid, $module, , $param, $extra] = func_get_args();
- $host = '';
- $r = [
- '{pluginid}' => $pluginid,
- '{module}' => $module,
- ];
- if($param) {
- $fextra = '?'.$param;
- }
- }
- $href = str_replace(array_keys($r), $r, $_G['setting']['rewriterule'][$type]).$fextra;
- if(!$returntype) {
- return '<a href="'.$host.$href.'"'.(!empty($extra) ? stripslashes($extra) : '').'>';
- } else {
- return $host.$href;
- }
- }
Copy Code Change these code into:
- function rewriteoutput($type, $returntype, $host) {
- global $_G;
- $fextra = '';
-
- // ========== SEO URLs for Discuz Latin characters title==========
- $seo_string = function($string, $max_length = 80) {
- if(empty($string)) return '';
- $string = preg_replace('/[^a-zA-Z0-9\s\-\p{L}]/u', '', $string);
- $string = preg_replace('/[\s\-]+/', '-', $string);
- $string = trim($string, '-');
- $string = mb_strtolower($string, 'UTF-8');
- if($max_length > 0 && mb_strlen($string, 'UTF-8') > $max_length) {
- $string = mb_substr($string, 0, $max_length, 'UTF-8');
- $string = rtrim($string, '-');
- }
- return $string;
- };
- // =========================================================
-
- if($type == 'forum_forumdisplay') {
- list(,,, $fid, $page, $extra) = func_get_args();
- $forum_name = DB::result_first("SELECT name FROM " . DB::table('forum_forum') . " WHERE fid='" . dintval($fid) . "'");
- $forum_seo = $seo_string($forum_name, 50);
-
- $r = array(
- '{fid}' => empty($_G['setting']['forumkeys'][$fid]) ? $fid : $_G['setting']['forumkeys'][$fid],
- '{page}' => $page ? $page : 1,
- '{forumname}' => $forum_seo,
- );
- } elseif($type == 'forum_viewthread') {
- list(,,, $tid, $page, $prevpage, $extra) = func_get_args();
- $thread_subject = DB::result_first("SELECT subject FROM " . DB::table('forum_thread') . " WHERE tid='" . dintval($tid) . "'");
- $thread_seo = $seo_string($thread_subject, 80);
-
- $r = array(
- '{tid}' => $tid,
- '{page}' => $page ? $page : 1,
- '{prevpage}' => $prevpage && !IS_ROBOT ? $prevpage : 1,
- '{subject}' => $thread_seo, //
- );
- } elseif($type == 'home_space') {
- list(,,, $uid, $username, $extra) = func_get_args();
- $_G['setting']['rewritecompatible'] && $username = rawurlencode($username);
- $r = array(
- '{user}' => $uid ? 'uid' : 'username',
- '{value}' => $uid ? $uid : $username,
- );
- } elseif($type == 'home_blog') {
- list(,,, $uid, $blogid, $extra) = func_get_args();
- $r = array(
- '{uid}' => $uid,
- '{blogid}' => $blogid,
- );
- } elseif($type == 'group_group') {
- list(,,, $fid, $page, $extra) = func_get_args();
- $r = array(
- '{fid}' => $fid,
- '{page}' => $page ? $page : 1,
- );
- } elseif($type == 'portal_topic') {
- list(,,, $name, $extra) = func_get_args();
- $r = array(
- '{name}' => $name,
- );
- } elseif($type == 'portal_article') {
- list(,,, $id, $page, $extra) = func_get_args();
- $article_title = DB::result_first("SELECT title FROM " . DB::table('portal_article_content') . " WHERE aid='" . dintval($id) . "'");
- $article_seo = $seo_string($article_title, 80);
-
- $r = array(
- '{id}' => $id,
- '{page}' => $page ? $page : 1,
- '{title}' => $article_seo,
- );
- } elseif($type == 'forum_archiver') {
- list(,, $action, $value, $page, $extra) = func_get_args();
- $host = '';
- $r = array(
- '{action}' => $action,
- '{value}' => $value,
- );
- if($page) {
- $fextra = '?page='.$page;
- }
- } elseif($type == 'plugin') {
- list(,, $pluginid, $module,, $param, $extra) = func_get_args();
- $host = '';
- $r = array(
- '{pluginid}' => $pluginid,
- '{module}' => $module,
- );
- if($param) {
- $fextra = '?'.$param;
- }
- }
- $href = str_replace(array_keys($r), $r, $_G['setting']['rewriterule'][$type]).$fextra;
- if(!$returntype) {
- return '<a href="'.$host.$href.'"'.(!empty($extra) ? stripslashes($extra) : '').'>';
- } else {
- return $host.$href;
- }
- }
Copy Code and Here is the rewrite rules for NGINX and APACHE servers:
NGINX
- <div>#
- RewriteRule ^forum-([a-zA-Z0-9\-]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$2&page=$3 [L,QSA]
- #
- RewriteRule ^thread-([0-9]+)-([a-zA-Z0-9\-]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&page=$3 [L,QSA]
- #
- RewriteRule ^forum-([0-9]+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2 [L,QSA]
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&page=$2 [L,QSA]</div>
Copy Code APACHE:
- <div>RewriteRule ^forum-([a-zA-Z0-9\-]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$2&page=$3 [L,QSA]
- RewriteRule ^thread-([0-9]+)-([a-zA-Z0-9\-]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&page=$3 [L,QSA]
- RewriteRule ^forum-([0-9]+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2 [L,QSA]
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&page=$2 [L,QSA]</div>
Copy Code
|
|