网络营销电子商务研究中心

网络营销电子商务研究中心 (https://www.0058.net/index.php)
-   DedeCMS (https://www.0058.net/forumdisplay.php?f=71)
-   -   做英文站的时候,为了url优化,设置生成文件名用文章标题。 (https://www.0058.net/showthread.php?t=4662)

topvip 2014-03-14 10:43 PM

做英文站的时候,为了url优化,设置生成文件名用文章标题。
 
但是遇到一个问题就是比如文章名是I LOVE YOU,dede生成的文章页是I_LOVE_YOU.htm.在搜索的眼里这个文件名就是ILOVEYOU.htm变成了一个无意义的单词。所以要把_变成-。这样生成的文件名是I-LOVE-YOU.htm。做英文站URL包含关键字是相当重要的。现把做法分享给大家,此方法从BLT大哥那里请教来的,自己还没去试,第一时间发过来。

打开 include/inc/inc_fun_funAdmin.php
[code]
for($i=0;$i<$slen;$i++){
if(ord($str[$i])>0x80)
{
$c = $str[$i].$str[$i+1];
$i++;
if(isset($pinyins[$c])){
if($ishead==0) $restr .= $pinyins[$c];
else $restr .= $pinyins[$c][0];
}else $restr .= "-";
}else if( eregi("[a-z0-9]",$str[$i]) ){ $restr .= $str[$i]; }
else{ $restr .= "-"; }
}
[code]

$restr .= "-"; 这些东西

完全引用他原话,完毕。


All times are GMT +8. The time now is 07:17 PM.

Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.