View: 3680|Reply: 5

Nhờ hướng dẫn chỉnh url tĩnh theo tiêu đề

[Copy link]
Posted on 17-4-2021 09:51:52 | Show all floors |Reading mode
Rất mong BQT có thể hướng dẫn giúp mình cách tạo url tĩnh bằng tiêu đề như trên diễn đàn của NĐV với ạ. Mình xin cảm ơn!


Reply

Use item Report

Posted on 23-7-2021 23:41:32 | Show all floors
bạn vào cài đặt chính nó có phần bật htaccess đó.
Reply GOOD NORMAL

Use item Report

 OP| Posted on 7-8-2021 12:06:00 | Show all floors
Saokim999 gửi lúc 23-7-2021 11:41 PM
bạn vào cài đặt chính nó có phần bật htaccess đó.

Nó chỉ hiện thị bằng số chứ không tự lấy tiêu đề làm liên kết tĩnh. Trình độ mình còn non nên không biết chỉnh htaccess tự lấy liên kết tĩnh từ tiêu đề bạn ơi!
Reply GOOD NORMAL

Use item Report

Posted on 18-8-2021 01:05:13 | Show all floors
Trước mình có viết hướng dẫn tạo link seo : http://forum.netdepviet.org/toi- ... ccess-5739-1-1.html , giờ tìm lại file đính kèm thì không thấy nữa.
Nay viết lại mấy dòng hi vọng giúp được bạn.

File cần sửa: /source/function/function_core.php
Tìm dòng:
  1. define('DISCUZ_CORE_FUNCTION', true);
Copy code

Thêm vào bên dưới:
  1. //SEO-URL for Discuz!X (c) Vic.0
  2. Tìm đến dòng:
  3. [code]'{fid}' => empty($_G['setting']['forumkeys'][$fid]) ? $fid : $_G['setting']['forumkeys'][$fid],
Copy code

Chỉnh thành:
  1. //SEO-URL (c) Vic.0
  2.                         '{tenbox}' => locdau(DB::result_first("SELECT name FROM ".DB::table('forum_forum')." WHERE fid='$fid'")),
  3.                         //End SEO-URL
Copy code

function locdau($value)
        {
        //bat dau loc dau
        $locdau_in = array (
        '#(A|Á|À|Ả|Ã|Ạ|Ä‚|Ắ|Ằ|Ẳ|Ẵ|Ặ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|á|à |ả|ã|ạ|ă|ắ|ằ|ẳ|ẵ|ặ|â|ấ|ầ|ẩ|ẫ|ậ)#',
        '#(B)#',
        '#(C)#',
        '#(D|Đ|Ä‘)#',
        '#(E|É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ|é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|á»…|ệ)#',
        '#(F)#',
        '#(G)#',
        '#(H)#',
        '#(I|Í|ÃŒ|Ỉ|Ĩ|Ị|í|ì|ỉ|Ä©|ị)#',
        '#(J)#',
        '#(K)#',
        '#(L)#',
        '#(M)#',
        '#(N)#',
        '#(O|Ó|Ã’|Ỏ|Õ|Ọ|Ô|Ố|á»’|á»”|á»–|Ộ|Æ |Ớ|Ờ|Ở|á» |Ợ|ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|á»—|á»™|Æ¡|á»›|ờ|ở|ỡ|ợ)#',
        '#(P)#',
        '#(Q)#',
        '#(R)#',
        '#(S)#',
        '#(T)#',
        '#(U|Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|á»®|á»°|ú|ù|á»§|Å©|ụ|ư|ứ|ừ|á»­|ữ|á»±)#',
        '#(V)#',
        '#(W)#',
        '#(X)#',
        '#(Ý|Ỳ|á»¶|Ỹ|á»´|Y|ý|ỳ|á»·|ỹ|ỵ|y)#',
        '#(Z)#',
        "/[^a-zA-Z0-9\-\_]/",
        '#(@)#',
        ) ;
        $locdau_out = array (
        'a',
        'b',
        'c',
        'd',
        'e',
        'f',
        'g',
        'h',
        'i',
        'j',
        'k',
        'l',
        'm',
        'n',
        'o',
        'p',
        'q',
        'r',
        's',
        't',
        'u',
        'v',
        'w',
        'x',
        'y',
        'z',
        '-',
        '-',
        ) ;

        $value = preg_replace($locdau_in, $locdau_out, $value);
        $value = preg_replace('/(-)+/', '-', $value);
        $value = str_replace(array('-quot', '"'), '', $value);
        //ket thuc loc dau
                return $value;
        }
//End SEO-URL[/code]

Tìm tiếp phần seo link cho bài viết
  1. elseif($type == 'forum_viewthread') {
Copy code


Sửa link thành:
  1. //SEO-URL (c) Vic.0
  2.                         '{tenbai}' => locdau(DB::result_first("SELECT subject FROM ".DB::table('forum_thread')." WHERE tid='$tid'")),
  3.                         //End SEO-URL
Copy code


Rồi sửa file htaccess
  1. <Files ~ "^\.(htaccess|htpasswd)[        DISCUZ_CODE_0        ]quot;>
  2. deny from all
  3. </Files>
  4. # RewriteEngine
  5. RewriteEngine On

  6. RewriteBase /
  7. ##your forum folder. If your forum: www.netdepviet.org/discuz/ .
  8. ## the RewriteBase is: RewriteBase /discuz
  9. # Rewrite
  10. RewriteCond %{QUERY_STRING} ^(.*)$
  11. RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topic=$1&%1
  12. RewriteCond %{QUERY_STRING} ^(.*)$
  13. RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
  14. RewriteCond %{QUERY_STRING} ^(.*)$
  15. RewriteRule ^(\w+)-([0-9]+)/(.*)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
  16. RewriteCond %{QUERY_STRING} ^(.*)$
  17. RewriteRule ^(.*)-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$2&$3&page=$3&%1
  18. RewriteCond %{QUERY_STRING} ^(.*)$
  19. RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
  20. RewriteCond %{QUERY_STRING} ^(.*)$
  21. RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
  22. RewriteCond %{QUERY_STRING} ^(.*)$
  23. RewriteRule ^([a-z]+)-(.+)\.html$ $1.php?rewrite=$2&%1
Copy code



Lưu ý:
Dùng tool compare với file gốc cho dễ edit nhé.
đây là file discuz_core mà mình đang dùng ( X3.2 ): http://forum.netdepviet.org/seo-url-tinh-discuz.txt
Reply GOOD NORMAL

Use item Report

 OP| Posted on 5-9-2021 00:09:43 | Show all floors
Bài được lks194 sửa lúc  5-9-2021 12:17 AM

Bài được lks194 sửa lúc  5-9-2021 12:16 AM

temtem gửi lúc 18-8-2021 01:05 AM
Trước mình có viết hướng dẫn tạo link seo : http://forum.netdepviet.org/toi-uu-seo-url-ban ...

Cảm ơn bạn đã hướng dẫn. Nhưng bạn có thể chỉnh sửa từ đoạn hướng dẫn chỉnh file htaccess trở lên giúp mình được không.
Chỗ Thêm vào bên dưới hình như nhầm code thì phải, và function locdau mình thêm ở đâu?





Tìm phần seo link là mình sửa ở file nào?


Reply GOOD NORMAL

Use item Report

Posted on 1-7-2024 16:33:24 | Show all floors
# Custom redirect rule: redirect /subfolder to subdomain
  1. RewriteEngine On
  2. RewriteCond %{REQUEST_URI} ^/discuz-forum($|/)
  3. RewriteRule ^discuz-forum(.*)$ http://forum.abcdomain.com$1 [R=301,L]
Copy code


Trường hợp này áp dụng cho 1 web chính chạy wordpress và diễn đàn dùng discuz
Reply GOOD NORMAL

Use item Report

You need to log in to reply. Login | Register

Points Rules for This Section

Theo dõi bản tin
Archiver|Mobile|Facebook|Contact|Netdepviet.org

Giữ gìn bản sắc dân tộc · Trân trọng quá khứ, hướng tới tương lai。

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

InThis boardPost
Kết nối Zalo
Back to top