發(fā)表日期:2019-09 文章編輯:小燈 瀏覽次數(shù):4042
示例:
http://www.***.com/sell/list-546.html? 列表頁
http://www.***.com/news/? 內(nèi)容頁
因為自己的需要,只寫了一個apache的規(guī)則,其它環(huán)境請自己擴展
把以下規(guī)則,找到根目錄下的? .htaccess 添加進(jìn)去
RewriteRule ^(.*)1([0-9]+)([0-9]+)?([/])?$ $1/show.php?itemid=$2&page=$3RewriteRule ^(.*)0([0-9]+)([0-9]+)?([/])?$ $1/list.php?catid=$2&page=$3
打開api/url.inc.php
搜索?
$urls['php']['list'][5] = array('example'=>'('.$L['url_rewrite'].') mulu-c1-2.html','index'=>'{$catdir}-c{$catid}-1.html', 'page'=>'{$catdir}-c{$catid}-{$page}.html');
在它下面添加
$urls['php']['list'][6] = array('example'=>'('.$L['url_rewrite'].') 01','index'=>'0{$catid}', 'page'=>'0{$catid}{$page}');
搜索
$urls['php']['item'][4] = array('example'=>'('.$L['url_rewrite'].') show/1/','index'=>'show/{$itemid}/', 'page'=>'show/{$itemid}/{$page}/');
在它下面添加
$urls['php']['item'][5] = array('example'=>'('.$L['url_rewrite'].') m15','index'=>'1{$itemid}', 'page'=>'1{$itemid}{$page}');
網(wǎng)站后臺,模塊設(shè)置,選擇新加的偽靜態(tài)規(guī)則,更新地址。
修改如商城模塊的目錄 mall為m, ?
這時我們通過后臺,或者網(wǎng)站前臺訪問內(nèi)容或分類網(wǎng)址是? http://www.***.com/m/12? 這樣的形式,要變成 http://www.***.com/m12?? 需要自己 修改 {$t[linkurl]} 這個標(biāo)簽了,這是因為我們的調(diào)用標(biāo)簽會給{$t[linkurl]} 自動加上頻道的網(wǎng)址,而每個頻道 的網(wǎng)址都是默認(rèn)以? /? 結(jié)束的,所以才有了這多出來的一? /??
這個可以用函數(shù)過慮下,如我的實際地址是: http://www.***.com/m/12? 那么過慮使用方法 ? {str_replac e("m/", "m", $t[linkurl]);} ,注:把c 和e之間的空格刪除,因為網(wǎng)站安全設(shè)置會過慮php函數(shù)的原因,不能連一起寫。
這樣就把/過慮掉了
下面是我擴展的一個函數(shù),可以判斷網(wǎng)站是否開啟偽靜態(tài),如果開啟就替換網(wǎng)址,復(fù)制函數(shù)加入include/global.func.php
//url根目錄化function duan_com($url){global $DT, $CFG;if(!$DT['rewrite']) return $url;if(subst($url,-1)=='/'){$url = subst($url,0,strlen($url)-1);}if(strstr($url,"/0")){$url = str_replac('/0', '0', "$url");}elseif(strstr($url,"/1")){$url = str_replac('/1', '1', "$url");if(strstr($url,"http:/1")){$url = str_replac('http:/1', 'http://1', "$url");}elseif(strstr($url,"http:/0")){$url = str_replac('http:/0', 'http://0', "$url");}}return $url;}
調(diào)用方法 {duan_com($t[linkurl])}
0日期:2019-09 瀏覽次數(shù):3909
日期:2019-09 瀏覽次數(shù):3697
日期:2019-09 瀏覽次數(shù):3696
日期:2019-09 瀏覽次數(shù):3610
日期:2019-09 瀏覽次數(shù):3609
日期:2019-09 瀏覽次數(shù):3612
日期:2019-09 瀏覽次數(shù):3656
日期:2019-09 瀏覽次數(shù):3711
日期:2019-09 瀏覽次數(shù):4041
日期:2019-09 瀏覽次數(shù):3531
日期:2019-09 瀏覽次數(shù):3618
日期:2019-09 瀏覽次數(shù):3311
日期:2019-09 瀏覽次數(shù):3322
日期:2019-09 瀏覽次數(shù):2994
日期:2019-09 瀏覽次數(shù):3031
日期:2019-09 瀏覽次數(shù):3013
日期:2019-09 瀏覽次數(shù):2998
日期:2019-09 瀏覽次數(shù):3119
日期:2019-09 瀏覽次數(shù):3065
日期:2019-09 瀏覽次數(shù):3266
日期:2019-09 瀏覽次數(shù):3154
日期:2019-09 瀏覽次數(shù):3337
日期:2019-09 瀏覽次數(shù):3050
日期:2019-09 瀏覽次數(shù):3387
日期:2019-09 瀏覽次數(shù):3252
日期:2019-09 瀏覽次數(shù):3246
日期:2019-09 瀏覽次數(shù):3127
日期:2019-09 瀏覽次數(shù):3164
日期:2019-09 瀏覽次數(shù):3024
日期:2019-09 瀏覽次數(shù):2970
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.