本文介绍的是系统API的rewrite配置
文章/栏目/标签的rewrite配置是独立配置的与本设置无关,
具体可以查看文章/栏目/标签的REWRITE配置
开启rewrite
位置:系统设置->URL设置
REWRITE 开启
iCMSv7.0.8 或者 开发版升级到 git:2018-03-30 之后可使用下面的规则
git:2018-03-30 新增
rewrite.php
伪静态统一解析程序
以下伪静态规则仅供参考
nginx
location / { index index.html index.htm index.php; try_files $uri $uri/ /rewrite.php?$args;}
apache
RewriteEngine onRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . rewrite.php [L]
IIS
<?xml version="1.0" encoding="UTF-8"?><configuration><system.webServer><rewrite><rules><rule name="ICMS" stopProcessing="true"><match url="^(.)$" ignoreCase="false" /><conditions logicalGrouping="MatchAll"><add input="{HTTP_HOST}" pattern="^(.)$" /><add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /><add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /></conditions><action type="Rewrite" url="rewrite.php" /></rule></rules></rewrite></system.webServer></configuration>
iCMSv7.0.7及以前版本 或者 开发版升级到 git:2018-03-30 之前使用旧版本规则
开启后 在下面会显示REWRITE配置.
这个一般不用修改,有做二次开发时可根据需要添加相关链接.
nginx配置
#用户APPrewrite "^/user$" /public/api.php?app=user last;#用户中心 我的首页rewrite "^/user/home$" /public/api.php?app=user&do=home last;#用户中心 我的内容rewrite "^/user/manage/(\w+)$" /public/api.php?app=user&do=manage&pg=$1 last;rewrite "^/user/manage$" /public/api.php?app=user&do=manage last;#发表文章 rewrite "^/user/publish$" /public/api.php?app=user&do=manage&pg=publish last;#我的文章rewrite "^/user/article$" /public/api.php?app=user&do=manage&pg=article last;#我的分类rewrite "^/user/category$" /public/api.php?app=user&do=manage&pg=category last;#我的评论rewrite "^/user/comment$" /public/api.php?app=user&do=manage&pg=comment last;#我的私信rewrite "^/user/inbox/(\d+)$" /public/api.php?app=user&do=manage&pg=inbox&user=$1 last;rewrite "^/user/inbox$" /public/api.php?app=user&do=manage&pg=inbox last;#用户中心 账号设置rewrite "^/user/profile/(\w+)$" /public/api.php?app=user&do=profile&pg=$1 last;rewrite "^/user/profile$" /public/api.php?app=user&do=profile last;#用户第三方登陆rewrite "^/user/login/(\w+)$" /public/api.php?app=user&do=login&sign=$1 last;#用户登陆rewrite "^/user/login$" /public/api.php?app=user&do=login last;#用户注册rewrite "^/user/register$" /public/api.php?app=user&do=register last;#用户退出rewrite "^/user/logout$" /public/api.php?app=user&do=logout last;#用户找回密码rewrite "^/user/findpwd$" /public/api.php?app=user&do=findpwd last;#用户主页#这里的前缀 /user/ 要根据 URL设置里的 用户URL 设置rewrite "^/user/(\d+)/(\w+)/$" /public/api.php?app=user&do=$2&uid=$1 last;rewrite "^/user/(\d+)/$" /public/api.php?app=user&do=home&uid=$1 last;rewrite "^/user/(\d+)/(\d+)/$" /public/api.php?app=user&do=home&uid=$1&cid=$2 last;rewrite "^/user/(\d+)/favorite/(\d+)/$" /public/api.php?app=user&do=favorite&uid=$1&id=$2 last;#系统APIrewrite "^/api$" /public/api.php last;#评论rewrite "^/comment$" /public/api.php?app=comment last;#搜索rewrite "^/search$" /public/api.php?app=search last; #公共API 验证码之类的rewrite "^/public/(\w+)$" /public/api.php?app=public&do=$1 last;#收藏功能rewrite "^/favorite$" /public/api.php?app=favorite last;rewrite "^/favorite/(\d+)/$" /public/api.php?app=favorite&id=$1 last;#自定义表单rewrite "^/forms$" /public/api.php?app=forms last;rewrite "^/forms/(\w+)$" /public/api.php?app=forms&do=$1 last;rewrite "^/forms/(\d+)/$" /public/api.php?app=forms&id=$1 last;
apache配置
文档完善中,敬请关注......
IIS配置
文档完善中,敬请关注......
REWRITE配置简单说明
下图为REWRITE配置格式化后
{ "user": [ "/user", "api.php?app=user" ], "user:home": [ "/user/home", "api.php?app=user&do=home" ], "user:publish": [ "/user/publish", "api.php?app=user&do=manage&pg=publish" ], "user:article": [ "/user/article", "api.php?app=user&do=manage&pg=article" ], "user:category": [ "/user/category", "api.php?app=user&do=manage&pg=category" ], "user:comment": [ "/user/comment", "api.php?app=user&do=manage&pg=comment" ], "user:inbox": [ "/user/inbox", "api.php?app=user&do=manage&pg=inbox" ], "user:inbox:uid": [ "/user/inbox/{uid}", "api.php?app=user&do=manage&pg=inbox&user={uid}" ], "user:manage": [ "/user/manage", "api.php?app=user&do=manage" ], "user:manage:favorite": [ "/user/manage/favorite", "api.php?app=user&do=manage&pg=favorite" ], "user:manage:fans": [ "/user/manage/fans", "api.php?app=user&do=manage&pg=fans" ], "user:manage:follow": [ "/user/manage/follow", "api.php?app=user&do=manage&pg=follow" ], "user:profile": [ "/user/profile", "api.php?app=user&do=profile" ], "user:profile:base": [ "/user/profile/base", "api.php?app=user&do=profile&pg=base" ], "user:profile:avatar": [ "/user/profile/avatar", "api.php?app=user&do=profile&pg=avatar" ], "user:profile:setpassword": [ "/user/profile/setpassword", "api.php?app=user&do=profile&pg=setpassword" ], "user:profile:bind": [ "/user/profile/bind", "api.php?app=user&do=profile&pg=bind" ], "user:profile:custom": [ "/user/profile/custom", "api.php?app=user&do=profile&pg=custom" ], "user:register": [ "/user/register", "api.php?app=user&do=register" ], "user:logout": [ "/user/logout", "api.php?app=user&do=logout" ], "user:login": [ "/user/login", "api.php?app=user&do=login" ], "user:login:qq": [ "/user/login/qq", "api.php?app=user&do=login&sign=qq" ], "user:login:wb": [ "/user/login/wb", "api.php?app=user&do=login&sign=wb" ], "user:login:wx": [ "/user/login/wx", "api.php?app=user&do=login&sign=wx" ], "user:findpwd": [ "/user/findpwd", "api.php?app=user&do=findpwd" ], "uid:home": [ "/{uid}/", "api.php?app=user&do=home&uid={uid}" ], "uid:comment": [ "/{uid}/comment/", "api.php?app=user&do=comment&uid={uid}" ], "uid:share": [ "/{uid}/share/", "api.php?app=user&do=share&uid={uid}" ], "uid:favorite": [ "/{uid}/favorite/", "api.php?app=user&do=favorite&uid={uid}" ], "uid:fans": [ "/{uid}/fans/", "api.php?app=user&do=fans&uid={uid}" ], "uid:follower": [ "/{uid}/follower/", "api.php?app=user&do=follower&uid={uid}" ], "uid:cid": [ "/{uid}/{cid}/", "api.php?app=user&do=home&uid={uid}&cid={cid}" ], "uid:favorite:id": [ "/{uid}/favorite/{id}/", "api.php?app=user&do=favorite&uid={uid}&id={id}" ], "api": [ "/api", "api.php" ], "comment": [ "/comment", "api.php?app=comment" ], "search": [ "/search", "api.php?app=search" ], "public:seccode": [ "/public/seccode", "api.php?app=public&do=seccode" ], "public:agreement": [ "/public/agreement", "api.php?app=public&do=agreement" ], "favorite": [ "/favorite", "api.php?app=favorite" ], "favorite:id": [ "/favorite/{id}/", "api.php?app=favorite&id={id}" ], "forms": [ "/forms", "api.php?app=forms" ], "forms:save": [ "/forms/save", "api.php?app=forms&do=save" ], "forms:id": [ "/forms/{id}/", "api.php?app=forms&id={id}" ]}
- 配置简单说明
"唯一标识": [ "伪静态链接", "动态链接" ]
例子
"user": [ "/user", //REWRITE开启后使用的链接 "api.php?app=user" //REWRITE关闭后使用的链接 ], "user:home": [ "/user/home", "api.php?app=user&do=home" ],
- 调用方式
<!--{iCMS:router url='user'}-->
<!--{iCMS:router url='user:home'}-->
希望以上内容对你有所帮助!如果还有其他问题,请随时提问。 各类知识收集 拥有多年CMS企业建站经验,对 iCMS, Fastadmin, ClassCMS, LeCMS, PbootCMS, PHPCMS, 易优CMS, YzmCMS, 讯睿CMS, 极致CMS, Wordpress, HkCMS, YznCMS, WellCMS, ThinkCMF, 等各类cms的相互转化,程序开发,网站制作,bug修复,程序杀毒,插件定制都可以提供最佳解决方案。