新闻列表页调用当前文章对应的tag标签:
{foreach explode(',',$v['tags']) as $s} {if($s)} {fun U('tags/index',['tagname'=>$v['keywords']])} {/if} {/foreach}
此时tag“北京”的链接是:
http://域名/tags/index/tagname/北京.html
如何进一步缩短链接呢,变成:
http://域名/tags/北京.html
一:修改新闻列表页模板调用代码
{foreach explode(',',$v['tags']) as $s} {if($s)} <a href="{fun U('tags/'.$s)}">{$s}</a> {/if} {/foreach}
二:修改conf/route.php
增加一行:
['/^/tags/(.*)/','tags/index/tagname/$1','GET'],