AKCMS 6.1实现全站伪静态

akcms系统安装之后,默认是动态的,要想全站伪静态核心就三点:

一,web服务器环境上做好伪静态规则

二,系统管理后台做好相应配置,

三,模板代码中有关URL的地方做好配置。

一般来说,要做伪静态就是为了SEO考虑,这种站主要把3类URL做好伪静态:
1,文章内容页(包括AKCMS里的单页),动态地址是www.xxoo.com/akcms_item.php?id=文章ID,伪静态后的地址可为:www.xxoo.com/item/文章ID.html
2,栏目页,动态地址是www.xxoo.com/akcms_category.php?path=栏目目录,若是多级栏目,动态地址是www.xxoo.com/akcms_category.php?path=上级栏目目录/下级栏目目录,伪静态后的地址可为:www.xxoo.com/栏目目录/www.xxoo.com/上级栏目目录/下级栏目目录/
3,栏目分页,动态地址是www.xxoo.com/akcms_category.php?path=栏目目录&page=分页号码,
伪静态后的地址可为:www.xxoo.com/栏目目录/index-分页号码.html

.下面是操作步骤:

一,对应的nginx伪静态规则为:

location /{
    rewrite ^/item/([0-9]+)\.html$ /akcms_item.php?id=$1 last;
    rewrite ^/([a-zA-Z0-9\-_\/]+)/$ /akcms_category.php?path=$1 last;
    rewrite ^/([a-zA-Z0-9\-_\/]+)/index-([0-9]+)\.html$ /akcms_category.php?path=$1&page=$2 last;
}

二,两个关键设置,在后台 → 设置 → 基本设置:
1,内容页第1套URL,设置为:item/[id].html,这样在模板函数getitems中,文章内容页的地址用[url]即可获取成伪静态地址。
2,栏目首页URL,设置为:[categorypath]/,这里一定不能设置为[path]/,不然多级栏目,在模板函数getcategories中,栏目首页的地址用[url]获取出来不是正确的路径,不包括上级目录。

[categorypath]:栏目目录(一直追踪到祖宗栏目的目录)
[path]:栏目目录(仅限自身的目录)

三,栏目的分页代码直接贴一个现成的好了:

<{getpaging page=$page currenttemplate="<li class='on'><a>[page]</a></li>" previoustemplate="<li><a href='[url]'>上一页</a></li>" noprevioustemplate="<li><a>上一页</a></li>" nexttemplate="<li><a href='[url]'>下一页</a></li>" nonexttemplate="<li><a>下一页</a></li>" template="<li><a href='[url]'>[page]</a></li>" paging="[first][previous][paging][next][last]" baseurl="[*home*]$path/index-[page].html" firstpage="[*home*]$path/"}>