Friendly SEO URL for Q2A

159 Likes Comment

A Q&A site ( based on Question2Answer.org platform ) helps your online community to share knowledge. People with questions get the answers they need. The community is enriched by commenting, voting, notifications, points and rankings.
How to rewrite friendly seo URL while using q2a?
File to edit : qa-include/qa-base.php
Find:
function qa_q_request($questionid, $title)
Add the following code above that function:
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

For Q2A Version 1.8.0 before:
Find:
$words=qa_string_to_words($title, true, false, false);
Add above:
$tieude=locdau($title);
Then go find:
return (int)$questionid.’/’.$title
Replace by:
return (int)$questionid.’/’.$tieude
For Q2A 1.8.0 later:
Find:
$title = qa_block_words_replace($title, qa_get_block_words_preg());
Add bellow it:
$tieude=locdau($title);
Find:
$slug = qa_slugify($title, qa_opt(‘q_urls_remove_accents’), qa_opt(‘q_urls_title_length’));
Replace by:
$slug = qa_slugify($tieude, qa_opt(‘q_urls_remove_accents’), qa_opt(‘q_urls_title_length’));
Save and upload the edited file.

You might like

Avatar

About the Author: Toc Xoan

Leave a Reply

Your email address will not be published. Required fields are marked *