Diễn đàn
› Wapmaster › PHP (Xenforo - JohnCMS - VBB - ZenCMS) › Hướng Dẫn Mod Rewrite Url Cho Johncms 4.4.0 Full › View post
![]() | NGUOIBANIT - Cấp bậc: ![]() |
![](http://aichat.wap.sh/icon/clock.png)
+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](https://xtgem.com/images/smilies/biggrin_mini2.gif)
VD mình có đường link mặc định sau http://vn4rum.net/forum/index.php?id=21 & sau khi mod rewrite sẽ là http://vn4rum.net/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á)
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]
Copy code
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]
Copy code
+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
/*
-----------------------------------------------------------------
Транслитерация текста
-----------------------------------------------------------------
*/
Copy code
-----------------------------------------------------------------
Транслитерация текста
-----------------------------------------------------------------
*/
Copy code
+Bước 3:
//Mở file index.php (forum)
Tìm dòng 226
Thay bằng
$tree[] = '<a href="'.$home.'/forum/' . functions::nhanhnao($res['text']) . '_' . $parent . '.html">' . $res['text'] . '</a>';
Copy code
Copy code
Tìm dòng 295
Thay bằng
echo '<a href="'.$home.'/forum/' . functions::nhanhnao($res['text']) . '_'.$res['id'].'.html">' . $res['text'] . '</a>';
Copy code
Copy code
Tìm dòng 344
echo '<a href="index.php?id=' . $res['id'] . '">' . $res['text'] . '</a> [' . $colmes1 . ']';
Copy code
Copy code
Thay bằng
echo '<a href="'.$home.'/forum/' . functions::nhanhnao($res['text']) . '_' . $res['id'] . '.html">' . $res['text'] . '</a> [' . $colmes1 . ']';
Copy code
Copy code
Tìm dòng 346
Thay bằng
echo '<a href="'.$home.'/forum/' . functions::nhanhnao($res['text']) . '_' . $res['id'] . '_p' . $cpg . '.html">*>></a>';
Copy code
Copy code
Tìm dòng 596
echo bbcode::notags($text) . '...<br /><a href="index.php?act=post&id=' . $res['id'] . '">' . $lng_forum['read_all'] . ' >></a>';
Copy code
Copy code
Thay bằng
echo bbcode::notags($text) . '...<br /><a href="'.$home.'/forum/' . functions::nhanhnao($type1['text']) . '_p' . $res['id'] . '.html">' . $lng_forum['read_all'] . ' >></a>';
Copy code
Copy code
Tìm dòng 755
echo '<a href="index.php?id=' . $res['id'] . '">' . $res['text'] . '</a> [' . $count . ']';
Copy code
Copy code
Thay bằng
echo '<a href="'.$home.'/forum/' . functions::nhanhnao($res['text']) . '_' . $res['id'] . '.html">' . $res['text'] . '</a> [' . $count . ']';
Copy code
Copy code
Tìm dòng 407
echo '<div class="topmenu">' . functions::display_pagination('index.php?id=' . $id . '&', $start, $colmes, $kmess) . '</div>';
Copy code
Copy code
Thay bằng
echo '<div class="topmenu">' . functions::display_pagination2(''.$home.'/forum/'.functions::nhanhnao($type1["text"]).'_' . $id, $start, $colmes, $kmess) . '</div>';
Copy code
Copy code
Tìm dòng 689
echo '<div class="topmenu">' . functions::display_pagination('index.php?id=' . $id . '&', $start, $colmes, $kmess) . '</div>' .
Copy code
Copy code
Thay =
echo '<div class="topmenu">' . functions::display_pagination2(''.$home.'/forum/'.functions::nhanhnao($type1["text"]).'_' . $id, $start, $colmes, $kmess) . '</div>' .
Copy code
Copy code
+Bước 4:
//Mở mainmenu.php (yêu cầu đã mod bài viết mới ra trang chủ)
+Tìm
echo ' <a href="/forum/index.php?id=' . $arr['id'] . ($cpg > 1 && $_SESSION['uppost'] ? '&clip&page=' . $cpg : '') . '">' . bbcode::tags($arr['text']) . '</a> [' . $colmes1 . ']';
Copy code
Copy code
+Thay bằng:
echo ' <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> [' . $colmes1 . ']';
Copy code
Copy code
+Tìm tiếp
echo ' <a href="/forum/index.php?id=' . $arr['id'] . ($_SESSION['uppost'] ? '' : '&clip&page=' . $cpg) . '#' . $nam['id'].'">>></a>';
Copy code
Copy code
+Thay bằng:
echo ' <a href="'.$home.'/forum/'.functions::nhanhnao($arr["text"]).'_' . $arr['id'] . (!$set_forum['upfp'] && $set_forum['postclip'] ? '_clip_' : '') . ($set_forum['upfp'] ? '' : '_p' . $cpg) . '.html">*>></a>';
Copy code
Copy code
Xong!
+Nếu có lỗi hãy lên diễn đàn update ngay nhá
Nguồn: vn4rum.net
Thành viên đang online:
Số khách đang online: 81