苹果cms伪静态及路由规则设置

一、说明

苹果CMS采用Thinkphp架构,内容以动态的形式展现出来,这对于搜索引擎及用户访问体验是非常不好的(动态模式下链接往往较长),通过设置伪静态路由规则,能简化url链接,同时也迎合了搜索引擎的算法,对网站seo优化有帮助。

注意:

  1. 在不清楚路由规则情况下不要随意修改,以免造成网站无法正常访问。
  2. 建议在网站正式上线前,设置好网站的伪静态及路由规则,避免后期改动,影响搜索引擎蜘蛛对网站的优化度。

二、Nginx下的伪静态配置

IIS、Nginx、Apache等环境下的伪静态设置方式不同,对于Nginx环境,登录宝塔后台,找到自己的网站设置

图片[1] - 苹果cms伪静态及路由规则设置 - 长江博客
宝塔后台:找到网站设置

找到“伪静态”,添加如下代码即可

location / {
  if (!-e $request_filename){
    rewrite  ^(.*)$  /index.php?s=$1  last;   break;
  }
}
}
图片[2] - 苹果cms伪静态及路由规则设置 - 长江博客
宝塔后台:伪静态设置

部分网站使用上述代码会出现除首页以外其他页面全部404 NO FOUND,则需要使用下列代码:

location / {
if (!-e $request_filename) {
        rewrite ^/index.php(.*)$ /index.php?s=$1 last;
        rewrite ^/admin.php(.*)$ /admin.php?s=$1 last;
        rewrite ^/api.php(.*)$ /api.php?s=$1 last;
        rewrite ^(.*)$ /index.php?s=$1 last;
        break;
        }
     }

三、苹果cms后台开启伪静态

最后一步操作,只需要在苹果cms后台,系统—>URL地址设置—>路由伪静态设置,中开启对应功能即可。

图片[3] - 苹果cms伪静态及路由规则设置 - 长江博客
苹果cms后台设置:开启伪静态和路由规则

四、修改路由规则

如果你想自定义苹果cms的路由规则就大胆的去修改DIY吧,如果出错的话可以使用下面的规则复原

map   => map/index
rss   => rss/index

index-<page?>   => index/index

gbook-<page?>   => gbook/index
gbook$   => gbook/index

topic-<page?>   => topic/index
topic$  => topic/index
topicdetail-<id>   => topic/detail

actor-<page?>   => actor/index
actor$ => actor/index
actordetail-<id>   => actor/detail
actorshow/<area?>-<blood?>-<sex?>-<starsign?>-<letter?>   => actor/show

role-<page?>   => role/index
role$ => role/index
roledetail-<id>   => role/detail
roleshow/<by?>-<letter?>-<level?>-<order?>-<page?>-<rid?>   => role/show

juqing<id>-<page?>   => plot/index
juqing$ => plot/index
juqing<id>  => plot/detail
juqing<id>-<page?>   => plot/detail

jisuyy<id>-<page?>   => vod/type
jisuyy<id>   => vod/type
jisu<id>   => vod/detail
vodrss-<id>   => vod/rss
play<id>-<sid>-<nid>   => vod/play
voddown/<id>-<sid>-<nid>   => vod/down
show<id>-<area?>-<by?>-<class?>-<lang?>-<letter?>-<level?>-<order?>-<page?>-<state?>-<tag?>-<year?>   => vod/show
vodsearch/<wd?>-<actor?>-<area?>-<by?>-<class?>-<director?>-<lang?>-<letter?>-<level?>-<order?>-<page?>-<state?>-<tag?>-<year?>   => vod/search

arttype/<id>-<page?>   => art/type
arttype/<id>   => art/type
artshow-<id>   => art/show
artdetail-<id>-<page?>   => art/detail
artdetail-<id>   => art/detail
artrss-<id>-<page>   => art/rss
artshow/<id>-<by?>-<class?>-<level?>-<letter?>-<order?>-<page?>-<tag?>   => art/show
artsearch/<wd?>-<by?>-<class?>-<level?>-<letter?>-<order?>-<page?>-<tag?>   => art/search

label-<file> => label/index
© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容