織夢內(nèi)容關(guān)鍵詞替換的時候存在一個錯誤:如果擁有兩個關(guān)鍵詞,例如“站長”(http://www.lalz.net)和“站長新聞”(http://www.lalz.net/news/news_17.html),但在文章替換的時候我們發(fā)現(xiàn)就會出現(xiàn)問題,鏈接變成了:
<a href="http://www.lalz.net">站長</a><a href="http://www.lalz.net/news/news_17.html">新聞</a>
解決方案
這樣的嵌套錯誤無論對SEO還是用戶體驗都是不好的,這里我們有一個解決方案,也就是先替換比較短的,然后再匹配替換長的,這樣系統(tǒng)則會先去替換Cit這個關(guān)鍵詞,而不會去替換CIT信息網(wǎng)了。
修改代碼
其實修改代碼很簡單,我們直接找到include/arc.archives.class.php這個文件,在1226行代碼,也就是:
//高亮專用, 替換多次是可能不能達(dá)到最多次 function _highlight($string, $words, $result, $pre) { global $cfg_replace_num; $string = str_replace('"', '"', $string); 后面增加一段代碼,使它變?yōu)?//高亮專用, 替換多次是可能不能達(dá)到最多次 function _highlight($string, $words, $result, $pre) { global $cfg_replace_num; $string = str_replace('"', '"', $string); uasort($words,create_function('$a, $b','return strlen($a)>strlen($b);'));
總結(jié)
DedeCMS對于SEO愛好者確實是一個利器,如何用好還需要深入琢磨。
未經(jīng)允許不得轉(zhuǎn)載:445IT之家 » DedeCMS關(guān)鍵詞替換含另一關(guān)鍵字問解決方案