View: 3139|Reply: 1

Tối ưu seo url cho website hỏi đáp question2answer

[Copy link]
Posted on 2-11-2014 18:00:23 | Show all floors |Reading mode
  Sau khi đã dựng xong một trang hỗ trợ khách hàng, trang hỏi đáp. Bạn cần tối ưu hóa một số thứ: giao diện gọn hơn, bố trí các chuyên mục hợp lý, chia sẻ trên các mạng xã hội về trang hỏi đáp của bạn. Rồi bước mà các webmaster quan tâm là SEO URL sao cho thân thiện nhất.
  Với các website  hỏi đáp là Tiếng Việt, Tiếng Trung, Tiếng Nhật, Tiếng Nga, Thái Lan...nếu dùng cách rewrite mặc định của q2a thì rất không thân thiện. Dưới đây là giải pháp cho bạn.

Rewrite friendly seo URL

File to edit :  qa-include/qa-base.php
Find:
  1. function qa_q_request($questionid, $title)
Copy code

Add the following code above that function:

  1. function locdau($value)
  2.     {
  3.     //bat dau loc dau
  4.     $locdau_in = array (
  5.     '#(A|Á|À|Ả|Ã|Ạ|Ă|Ắ|Ằ|Ẳ|Ẵ|Ặ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|á|à|ả|ã|ạ|ă|ắ|ằ|ẳ|ẵ|ặ|â|ấ|ầ|ẩ|ẫ|ậ)#',
  6.     '#(B)#',
  7.     '#(C)#',
  8.     '#(D|Đ|đ)#',
  9.     '#(E|É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ|é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ)#',
  10.     '#(F)#',
  11.     '#(G)#',
  12.     '#(H)#',
  13.     '#(I|Í|Ì|Ỉ|Ĩ|Ị|í|ì|ỉ|ĩ|ị)#',
  14.     '#(J)#',
  15.     '#(K)#',
  16.     '#(L)#',
  17.     '#(M)#',
  18.     '#(N)#',
  19.     '#(O|Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ỗ|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ|ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ)#',
  20.     '#(P)#',
  21.     '#(Q)#',
  22.     '#(R)#',
  23.     '#(S)#',
  24.     '#(T)#',
  25.     '#(U|Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự|ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự)#',
  26.     '#(V)#',
  27.     '#(W)#',
  28.     '#(X)#',
  29.     '#(Ý|Ỳ|Ỷ|Ỹ|Ỵ|Y|ý|ỳ|ỷ|ỹ|ỵ|y)#',
  30.     '#(Z)#',
  31.     "/[^a-zA-Z0-9\-\_]/",
  32.     '#(@)#',
  33.     ) ;
  34.     $locdau_out = array (
  35.     'a',
  36.     'b',
  37.     'c',
  38.     'd',
  39.     'e',
  40.     'f',
  41.     'g',
  42.     'h',
  43.     'i',
  44.     'j',
  45.     'k',
  46.     'l',
  47.     'm',
  48.     'n',
  49.     'o',
  50.     'p',
  51.     'q',
  52.     'r',
  53.     's',
  54.     't',
  55.     'u',
  56.     'v',
  57.     'w',
  58.     'x',
  59.     'y',
  60.     'z',
  61.     '-',
  62.     '-',
  63.     ) ;

  64.     $value = preg_replace($locdau_in, $locdau_out, $value);
  65.     $value = preg_replace('/(-)+/', '-', $value);
  66.     $value = str_replace(array('-quot', '"'), '', $value);
  67.     //ket thuc loc dau
  68.         return $value;
  69.     }
  70. //End netdepviet SEO-URL
Copy code

Continue to find:
  1. $words=qa_string_to_words($title, true, false, false);
Copy code

Add this above:
  1. $tieude=locdau($title);
Copy code

Then go to find:
  1. return (int)$questionid.'/'.$title
Copy code

Replace by:
  1. return (int)$questionid.'/'.$tieude
Copy code


Save and upload to the q2a site. No need to change the .htaccess file configuration .

* another way for other language:

  1. $unitit = str_replace(array('а', 'б', 'в', 'г', 'д', 'е', 'ё', 'ж', 'з', 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'щ', 'ь', 'ъ', 'ы', 'э', 'ю', 'я'), array('a', 'b', 'v', 'g', 'd', 'e', 'jo', 'zh', 'z', 'i', 'i', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'f', 'h', 'ts', 'ch', 'sh', 'sch', 'j', 'j', 'y', 'e', 'y', 'ya'), $title);
  2. //and make change something like this
  3. return (int)$questionid.'/'.$unitit;
Copy code



Reply

Use item Report

Posted on 26-2-2018 15:40:12 | Show all floors
For Question2Answer 1.8.0 (Released 08.02.2018 )or later:
Find:
  1. $title = qa_block_words_replace($title, qa_get_block_words_preg());
Copy code

Add bellow it:
  1. $tieude=locdau($title);
Copy code

Find:
  1. $slug = qa_slugify($title, qa_opt('q_urls_remove_accents'), qa_opt('q_urls_title_length'));
Copy code

Replace by:
  1. $slug = qa_slugify($tieude, qa_opt('q_urls_remove_accents'), qa_opt('q_urls_title_length'));
Copy code

Save and upload the edited file.
Reply GOOD 1 NORMAL 0

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