Share Hướng dẫn mod Rewrite Url cho JohnCMS 4.4.0 Full

D

dgtupltn95

New Member
Hướng dẫn mod Rewrite Url cho
JohnCMS 4.4.0 Full

+JohnCMS 4.4.0 tại Việt Nam
+Mod Rewrite URL Forum cho JohnCMS 4.4.0

Mục đích chủ yếu của mod rewrite (viết lại) là để cho đường link thân thiện và dễ seo hơn.
Sau đâu mình sẽ hướng dẫn tất cả về mod rewrite :D
VD mình có đường link mặc định sau http://nhanhnao.us/forum/index.php?id=21 & sau khi mod rewrite sẽ là http://nhanhnao.us/forum/johncms-4x_12.html (đẹp rồi đúng không)

+Các tệp cần tác động:
1. Index.php (forum)
2. functions.php
3. .htaccess (root)
4. mainmenu.php

+Bước 1:
//Mở file .htaccess (root)

Chèn đoạn sau vào (lưu ý không có chữ <?php ?> nhá)

PHP:
RewriteRule ^forum/(.*)_([0-9]+).html$ forum/index.php?id=$2 [L]
RewriteRule ^forum/(.*)_([0-9]+)_p([0-9]+).html$ forum/index.php?id=$2&page=$3 [L]
RewriteRule ^forum/(.*)_p([0-9]+).html$ forum/index.php?act=post&id=$2 [L]
RewriteRule ^forum/(.*)_([0-9]+)_s([0-9]+).html$ forum/index.php?id=$2&start=$3 [L]
RewriteRule ^forum/(.*)_([0-9]+)_clip_p([0-9]+).html$ forum/index.php?id=$2&clip&page=$3 [L]

+Bước 2: Tải file function.zip bên dưới rồi copy tất cả code bên trong file .txt rồi dán và sau
PHP:
/*
    -----------------------------------------------------------------
    Транслитерация текста
    -----------------------------------------------------------------
    */

+Bước 3:
//Mở file index.php (forum)

Tìm dòng 226

PHP:
$tree[] = '<a href="index.php?id=' . $parent . '">' . $res['text'] . '</a>';
Thay bằng
PHP:
$tree[] = '<a href="'.$home.'/forum/' . functions::nhanhnao($res['text']) . '_' . $parent . '.html">' . $res['text'] . '</a>';

Tìm dòng 295
PHP:
echo '<a href="?id=' . $res['id'] . '">' . $res['text'] . '</a>';
Thay bằng
PHP:
echo '<a href="'.$home.'/forum/' . functions::nhanhnao($res['text']) . '_'.$res['id'].'.html">' . $res['text'] . '</a>';

Tìm dòng 344
PHP:
echo '<a href="index.php?id=' . $res['id'] . '">' . $res['text'] . '</a> [' . $colmes1 . ']';
Thay bằng
PHP:
echo '<a href="'.$home.'/forum/' . functions::nhanhnao($res['text']) . '_' . $res['id'] . '.html">' . $res['text'] . '</a> [' . $colmes1 . ']';

Tìm dòng 346
PHP:
echo '<a href="index.php?id=' . $res['id'] . '&amp;page=' . $cpg . '">*&gt;&gt;</a>';
Thay bằng
PHP:
echo '<a href="'.$home.'/forum/' . functions::nhanhnao($res['text']) . '_' . $res['id'] . '_p' . $cpg . '.html">*&gt;&gt;</a>';

Tìm dòng 596
PHP:
echo bbcode::notags($text) . '...<br /><a href="index.php?act=post&amp;id=' . $res['id'] . '">' . $lng_forum['read_all'] . ' &gt;&gt;</a>';
Thay bằng
PHP:
echo bbcode::notags($text) . '...<br /><a href="'.$home.'/forum/' . functions::nhanhnao($type1['text']) . '_p' . $res['id'] . '.html">' . $lng_forum['read_all'] . ' &gt;&gt;</a>';

Tìm dòng 755
PHP:
echo '<a href="index.php?id=' . $res['id'] . '">' . $res['text'] . '</a> [' . $count . ']';
Thay bằng
PHP:
echo '<a href="'.$home.'/forum/' . functions::nhanhnao($res['text']) . '_' . $res['id'] . '.html">' . $res['text'] . '</a> [' . $count . ']';

Tìm dòng 407
PHP:
echo '<div class="topmenu">' . functions::display_pagination('index.php?id=' . $id . '&amp;', $start, $colmes, $kmess) . '</div>';
Thay bằng
PHP:
echo '<div class="topmenu">' . functions::display_pagination2(''.$home.'/forum/'.functions::nhanhnao($type1["text"]).'_' . $id, $start, $colmes, $kmess) . '</div>';

Tìm dòng 689
PHP:
echo '<div class="topmenu">' . functions::display_pagination('index.php?id=' . $id . '&amp;', $start, $colmes, $kmess) . '</div>' .
Ganti dengan kode
PHP:
echo '<div class="topmenu">' . functions::display_pagination2(''.$home.'/forum/'.functions::nhanhnao($type1["text"]).'_' . $id, $start, $colmes, $kmess) . '</div>' .

+Bước 4:
//Mở mainmenu.php (yêu cầu đã mod bài viết mới ra trang chủ)
+Tìm
PHP:
echo '&nbsp;<a href="/forum/index.php?id=' . $arr['id'] . ($cpg > 1 && $_SESSION['uppost'] ? '&amp;clip&amp;page=' . $cpg : '') . '">' . bbcode::tags($arr['text']) . '</a>&nbsp;[' . $colmes1 . ']';
+Thay bằng:
PHP:
echo '&nbsp;<a href="'.$home.'/forum/'.functions::nhanhnao($arr["text"]).'_' . $arr['id'] . ($cpg > 1 && $set_forum['upfp'] && $set_forum['postclip'] ? '_clip_' : '') . ($set_forum['upfp'] && $cpg > 1 ? '_p' . $cpg : '.html') . '">' . bbcode::tags($arr['text']) . '</a>&nbsp;[' . $colmes1 . ']';

+Tìm tiếp
PHP:
echo '&nbsp;<a href="/forum/index.php?id=' . $arr['id'] . ($_SESSION['uppost'] ? '' : '&amp;clip&amp;page=' . $cpg) . '#' . $nam['id'].'">&gt;&gt;</a>';
+Thay bằng:
PHP:
echo '&nbsp;<a href="'.$home.'/forum/'.functions::nhanhnao($arr["text"]).'_' . $arr['id'] . (!$set_forum['upfp'] && $set_forum['postclip'] ? '_clip_' : '') . ($set_forum['upfp'] ? '' : '_p' . $cpg) . '.html">*&gt;&gt;</a>';
 

Facebook Comments

Similar threads

S
Replies
0
Views
978
Sjeunhanleech
S
Back
Top