icms伪静态规则语法
7.0以后版本
nginx
apache
IIS
7.0以前版本及正在使用的规则
开启 伪静态(rewrite)
iCMS的应用rewrite需要在栏目设置
中开启
没开启前以动态链接显示
应用 | 链接 | 分页链接 |
---|---|---|
栏目/分类 | /category.php?cid=1 | /category.php?cid=1&page=1 |
文章 | /article.php?id=1 | /article.php?id=1&p=1 |
标签 | /tag.php?id=1 | /tag.php?id=1&page=1 |
选择栏目设置 ->URL规则设置->访问模式
然后设置URL规则
静态目录
一般为栏目名自动生成的拼音,可以自定义
栏目URL规则
举个栗子
- 栏目目录
规则 | 生成链接 |
---|---|
{CDIR}/index{EXT} | http://www.ooxx.com/test/index.html |
/{CDIR}/ | http://www.ooxx.com/test/ |
/{CDIR} | http://www.ooxx.com/test |
/ooxx/{CDIR} | http://www.ooxx.com/ooxx/test |
- 栏目ID
规则 | 生成链接 |
---|---|
/{CID}/ | http://www.ooxx.com/1/ |
/{CID} | http://www.ooxx.com/1 |
/ooxx/{CID}/ | http://www.ooxx.com/ooxx/1/ |
栏目规则有{CID}的 rewrite
/{CID}/
-
nginx
-
apache
/ooxx/{CID}/
-
nginx
-
apache
/list-{CID}-{P}.html
-
nginx
-
apache
栏目规则有{CDIR}的 rewrite
/{CDIR}/
-
nginx
-
apache
/ooxx/{CDIR}/
-
nginx
-
apache
栏目的分页规则跟栏目的首页规则是一样的
但是{P}
要对应&page=
内容规则
就是文章的URL
举个栗子
规则 | 链接 |
---|---|
{CDIR}/{YYYY}/{MM}{DD}/{ID}{EXT} | http://www.ooxx.com/test/2015/0115/1.html |
{CDIR}/{ID}.html | http://www.ooxx.com/test/1.html |
/ooxx/{ID}.html | http://www.ooxx.com/ooxx/1.html |
/a/{ID}.html | http://www.ooxx.com/a/1.html |
/a/{0xID}.html | http://www.ooxx.com/a/0000001.html |
/{CDIR}/{LINK}{EXT} | http://www.ooxx.com/test/自定义链接.html |
一般要包含{ID}
或者{0xID}
或者{LINK}
文章rewrite
{CDIR}/{YYYY}/{MM}{DD}/{ID}{EXT}
-
nginx
-
apache
{CDIR}/{ID}.html
-
nginx
-
apache
/a/{0xID}.html
-
nginx
-
apache
其它的以此类推
标签的rewrite
标签URL规则
规则 | 链接 |
---|---|
{PHP} | /tag.php?id=1 |
{ID} | http://www.ooxx.com/tag/1 |
{TKEY} | http://www.ooxx.com/tag/test |
{ZH_CN} | http://www.ooxx.com/tag/中文 |
{ID}
-
nginx
-
apache
{TKEY}
-
nginx
-
apache
{ZH_CN}或者 {NAME}
-
nginx
-
apache
IIS的rewrite 自己根据上面的规则修改下
程序后台配置如图
如果您的配置跟图中有不同之处
下面规则请做相应该的修改
你要原封不动复制粘贴,造成访问不了。
那就好自为之吧,我只能帮你到这了
到于什么是Rewrite,APACHE/nginx怎么设置Rewrite 请自行google
APACHE版
RewriteEngine on
RewriteBase /
RewriteRule ^u/(\d+)/$ user.php?do=home&uid=$1 [QSA,L]
RewriteRule ^u/(\d+)/(\d+)/$ user.php?do=home&uid=$1&cid=$2 [L]
RewriteRule ^u/(\d+)/(\w+)/$ user.php?do=$2&uid=$1 [L]
RewriteRule ^user$ user.php [QSA,L]
RewriteRule ^user/home$ user.php?do=home [L]
RewriteRule ^user/manage$ user.php?do=manage [L]
RewriteRule ^user/profile$ user.php?do=profile [L]
RewriteRule ^user/([^\/]\w+)$ user.php?do=manage&pg=$1 [QSA,L]
RewriteRule ^user/manage/(\w+)$ user.php?do=manage&pg=$1 [QSA,L]
RewriteRule ^user/inbox/(\d+)$ user.php?do=manage&pg=inbox&user=$1 [L]
RewriteRule ^user/profile/(\w+)$ user.php?do=profile&pg=$1 [L]
RewriteRule ^api$ public/api.php [QSA,L]
RewriteRule ^api/([^\/]\w+)$ public/api.php?app=$1 [QSA,L]
RewriteRule ^api/(\w+)/(\w+)$ public/api.php?app=$1&do=$2 [QSA,L]
RewriteRule ^api/user/login/(\w+)$ public/api.php?app=user&do=login&sign=$1 [L]
nginx版
rewrite "^/u/(\d+)/$" /user.php?do=home&uid=$1 last;
rewrite "^/u/(\d+)/(\d+)/$" /user.php?do=home&uid=$1&cid=$2 last;
rewrite "^/u/(\d+)/(\w+)/$" /user.php?do=$2&uid=$1 last;
rewrite "^/user$" /user.php last;
rewrite "^/user/home$" /user.php?do=home last;
rewrite "^/user/manage$" /user.php?do=manage last;
rewrite "^/user/profile$" /user.php?do=profile last;
rewrite "^/user/([^\/]\w+)$" /user.php?do=manage&pg=$1 last;
rewrite "^/user/manage/(\w+)$" /user.php?do=manage&pg=$1 last;
rewrite "^/user/inbox/(\d+)$" /user.php?do=manage&pg=inbox&user=$1 last;
rewrite "^/user/profile/(\w+)$" /user.php?do=profile&pg=$1 last;
rewrite "^/api$" /public/api.php last;
rewrite "^/api/([^\/]\w+)$" /public/api.php?app=$1 last;
rewrite "^/api/(\w+)/(\w+)$" /public/api.php?app=$1&do=$2 last;
rewrite "^/api/user/login/(\w+)$" /public/api.php?app=user&do=login&sign=$1 last;
栏目/文章/标签 Rewrite规则说明
很人在问iCMS 伪静态(rewrite)怎么设置
iCMS的URL规则都是可以自定义的
可以组成各种各样的URL
就看您喜欢什么样的
下面简单介绍下常用的设置
开启 伪静态(rewrite)
iCMS的rewrite需要在栏目设置中开启
没开启的 都以动态链接显示
/category.php?cid=1
/article.php?id=1
/tag.php?id=1
栏目设置 ->访问模式 选择
然后设置URL规则
静态目录:一般为栏目名的拼音 可以自定义
栏目规则
就是栏目的URL规则
举个栗子
截图中的
{CDIR}/index{EXT}
生成的栏目URL为:http://www.ooxx.com/test/index.html
如果想生成不带index.html
/{CDIR}/
生成的栏目URL为:http://www.ooxx.com/test/
如果想生成最后不带 /
/{CDIR}
生成的栏目URL为:http://www.ooxx.com/test
如果想生成用带栏目ID
/{CID}/ http://www.ooxx.com/1/
/{CID} http://www.ooxx.com/1
/ooxx/{CID}/ http://www.ooxx.com/ooxx/1/
栏目规则有{CID}的 rewrite
/{CID}/
nginx
rewrite "^/(\d+)(/|/index\.html)$" /category.php?cid=$1 last;
rewrite "^/(\d+)/index_(\d+).html$" /category.php?cid=$1&page=$2 last; #这个是分页
apache
RewriteRule ^(\d+)(/|/index\.html)$ category.php?cid=$1 [L]
RewriteRule ^(\d+)/index_(\d+).html$ category.php?cid=$1&page=$2 [L]
/ooxx/{CID}/
nginx
rewrite "^/ooxx/(\d+)(/|/index\.html)$" /category.php?cid=$1 last;
rewrite "^/ooxx/(\d+)/index_(\d+).html$" /category.php?cid=$1&page=$2 last; #这个是分页
apache
RewriteRule ^ooxx/(\d+)(/|/index\.html)$ category.php?cid=$1 [L]
RewriteRule ^ooxx/(\d+)/index_(\d+).html$ category.php?cid=$1&page=$2 [L]
/list-{CID}-{P}.html
nginx
rewrite "^/list-(\d+)-(\d+).html$" /category.php?cid=$1&page=$2 last;
apache
RewriteRule ^list-(\d+)-(\d+).html$ category.php?cid=$1&page=$2 [L]
栏目规则有{CDIR}的 rewrite
/{CDIR}/
nginx
rewrite "^/(\w+)(/|/index\.html)$" /category.php?dir=$1 last;
rewrite "^/(\w+)/index_(\d+).html$" /category.php?dir=$1&page=$2 last; #这个是分页
apache
RewriteRule ^(\w+)/$ category.php?dir=$1 [L]
RewriteRule ^(\w+)/index.html$ category.php?dir=$1 [L]
RewriteRule ^(\w+)/index_(\d+).html$ category.php?dir=$1&page=$2 [L]
/ooxx/{CDIR}/
nginx
rewrite "^/ooxx/(\w+)(/|/index\.html)$" /category.php?dir=$1 last;
rewrite "^/ooxx/(\w+)/index_(\d+).html$" /category.php?dir=$1&page=$2 last;
apache
RewriteRule ^ooxx/(\w+)/$ category.php?dir=$1 [L]
RewriteRule ^ooxx/(\w+)/index.html$ category.php?dir=$1 [L]
RewriteRule ^ooxx/(\w+)/index_(\d+).html$ category.php?dir=$1&page=$2 [L]
内容规则
就是文章的URL
还是举个栗子
截图中的
{CDIR}/{YYYY}/{MM}{DD}/{ID}{EXT}
生成的文章URL为:http://www.ooxx.com/test/2015/0115/1.html
太长了 没关系
咱设置成
{CDIR}/{ID}.html
生成的文章URL为:http://www.ooxx.com/test/1.html
太没个性了 没关系
/ooxx/{ID}.html
生成的文章URL为:http://www.ooxx.com/ooxx/1.html
太黄了
/a/{ID}.html
生成的文章URL为:http://www.ooxx.com/a/1.html
还是没个性
/a/{0xID}.html
生成的文章URL为:http://www.ooxx.com/a/0000001.html
一般要包含{ID}或{0xID}
文章rewrite
{CDIR}/{YYYY}/{MM}{DD}/{ID}{EXT}
nginx
rewrite "^/\w+/\d+/\d+/(\d+).html$" /article.php?id=$1 last;
rewrite "^/\w+/\d+/\d+/(\d+)_(\d+).html$" /article.php?id=$1&p=$2 last;
apache
RewriteRule ^\w+/\d+/\d+/(\d+).html$ article.php?id=$1 [L]
RewriteRule ^\w+/\d+/\d+/(\d+)_(\d+).html$ article.php?id=$1&p=$2 [L]
{CDIR}/{ID}.html
nginx
rewrite "^/\w+/(\d+).html$" /article.php?id=$1 last;
rewrite "^/\w+/(\d+)_(\d+).html$" /article.php?id=$1&p=$2 last;
apache
RewriteRule ^\w+/(\d+).html$ article.php?id=$1 [L]
RewriteRule ^\w+/(\d+)_(\d+).html$ article.php?id=$1&p=$2 [L]
/a/{0xID}.html
nginx
rewrite "^/a/(\d+).html$" /article.php?id=$1 last;
rewrite "^/a/(\d+)_(\d+).html$" /article.php?id=$1&p=$2 last;
apache
RewriteRule ^a/(\d+).html$ article.php?id=$1 [L]
RewriteRule ^a/(\d+)_(\d+).html$ article.php?id=$1&p=$2 [L]
其它的以此类推
标签的rewrite
标签rewrite设置在系统设置里 标签设置
标签URL:就是标签的URL
例:
标签URL规则
{PHP} 动态显示 /tag.php?id=1
{ID} 伪静态 http://www.ooxx.com/tag/1
{TKEY} 伪静态 http://www.ooxx.com/tag/test
{ZH_CN} 伪静态 http://www.ooxx.com/tag/中文
{ID}
nginx
rewrite "^/tag/(\d+)(/|/index\.html)$" /tag.php?id=$1 last;
rewrite "^/tag/(\d+)/index_(\d+).html$" /tag.php?id=$1&page=$2 last;
apache
RewriteRule ^tag/(\d+)$ tag.php?id=$1 [L]
RewriteRule ^tag/(\d+)/index.html$ tag.php?id=$1 [L]
RewriteRule ^tag/(\d+)/index_(\d+).html$ tag.php?id=$1&page=$2 [L]
{TKEY}
nginx
rewrite "^/tag/(\w+)(/|/index\.html)$" /tag.php?tkey=$1 last;
rewrite "^/tag/(\w+)/index_(\d+).html$" /tag.php?tkey=$1&page=$2 last;
apache
RewriteRule ^tag/(\w+)$ tag.php?tkey=$1 [L]
RewriteRule ^tag/(\w+)/index.html$ tag.php?tkey=$1 [L]
RewriteRule ^tag/(\w+)/index_(\d+).html$ tag.php?tkey=$1&page=$2 [L]
{ZH_CN} {NAME}
nginx
rewrite "^/tag/(.+)(/|/index\.html)$" /tag.php?name=$1 last;
rewrite "^/tag/(.+)/index_(\d+).html$" /tag.php?name=$1&page=$2 last;
apache
RewriteRule ^tag/(.+)$ tag.php?name=$1 [L]
RewriteRule ^tag/(.+)/index.html$ tag.php?name=$1 [L]
RewriteRule ^tag/(.+)/index_(\d+).html$ tag.php?name=$1&page=$2 [L]
PS:IIS的rewrite跟apache 差不多
在此就不做介绍
有人想说 我不清楚rewrite是什么...
那就自己google 百度一下 先自己搞清楚了
栏目 文章 标签 Rewrite规则 示例
程序后台配置如图 标签设置
如果您的配置跟图中有不同之处
下面规则请做相应该的修改
你要原封不动复制粘贴,造成访问不了。
那就好自为之吧,我只能帮你到这了
到于什么是Rewrite,APACHE/nginx怎么设置Rewrite 请自行google
注:最后设置完成 最好看下最终的网址路径是什么样子的 如果包含/html/test/index.html
/html/2016/12/12/123.html
可在 把/html/
换成/
APACHE版 IIS的跟APACHE差不多
RewriteEngine on
RewriteBase /
##标签
RewriteRule ^tag/(\w+)$ tag.php?tkey=$1 [L]
RewriteRule ^tag/(\w+)/index_(\d+).html$ tag.php?tkey=$1&page=$2 [L]
##文章
RewriteRule ^\w+/\d+/\d+/(\d+).html$ article.php?id=$1 [L]
RewriteRule ^\w+/\d+/\d+/(\d+)_(\d+).html$ article.php?id=$1&p=$2 [L]
##栏目
RewriteRule ^(\w+)/$ category.php?dir=$1 [L]
RewriteRule ^(\w+)/index.html$ category.php?dir=$1 [L]
RewriteRule ^(\w+)/index_(\d+).html$ category.php?dir=$1&page=$2 [L]
nginx版
##标签
rewrite "^/tag/(\w+)/$" /tag.php?tkey=$1 last;
rewrite "^/tag/(\w+)/index.html$" /tag.php?tkey=$1 last;
rewrite "^/tag/(\w+)/index_(\d+).html$" /tag.php?tkey=$1&page=$2 last;
##文章
rewrite "^/\w+/\d+/\d+/(\d+).html$" /article.php?id=$1 last;
rewrite "^/\w+/\d+/\d+/(\d+)_(\d+).html$" /article.php?id=$1&p=$2 last;
##栏目
rewrite "^/(\w+)/$" /category.php?dir=$1 last;
rewrite "^/(\w+)/index.html$" /category.php?dir=$1 last;
rewrite "^/(\w+)/index_(\d+).html$" /category.php?dir=$1&page=$2 last;
IIS版企业网站实战伪静态规则
#标签是iis7.5下正在使用的
#
<?xml version="1.0" ?> <rules> <rule name="article_page_rewrite" stopProcessing="true"> <match ignoreCase="false" url="^\w+/\d+/\d+\d+/(\d+)_(\d+).html$"/> <action appendQueryString="false" type="Rewrite" url="article.php?id={R:1}&page={R:2}"/> </rule> <rule name="article_rewrite" stopProcessing="true"> <match ignoreCase="false" url="^\w+/\d+/\d+\d+/(\d+).html$"/> <action appendQueryString="false" type="Rewrite" url="article.php?id={R:1}"/> </rule> <rule name="tag_page_rewrite" stopProcessing="true"> <match ignoreCase="false" url="^/tag/\w+/(.+)_(\d+).html$"/> <action appendQueryString="false" type="Rewrite" url="tag.php?tkey={R:1}&page={R:2}"/> </rule> <rule name="tag_rewrite" stopProcessing="true"> <match ignoreCase="false" url="^/tag/\w+/(.+).html$"/> <action appendQueryString="false" type="Rewrite" url="tag.php?tkey={R:1}"/> </rule> <rule name="list_rewrite" stopProcessing="true"> <match ignoreCase="false" url="^(\w+)/index_(\d+).html$"/> <action appendQueryString="false" type="Rewrite" url="category.php?dir={R:1}&page={R:2}"/> </rule> <rule name="index_rewrite" stopProcessing="true"> <match ignoreCase="false" url="^(\w+)/$"/> <action appendQueryString="false" type="Rewrite" url="category.php?dir={R:1}"/> </rule> <rule name="article1_rewrite" stopProcessing="true"> <match ignoreCase="false" url="^wxblog/(\w+).html$"/> <action appendQueryString="false" type="Rewrite" url="article.php?HASHID={R:1}"/> </rule> <rule name="search1_rewrite" stopProcessing="true"> <match ignoreCase="false" url="^search/(.*)$"/> <action appendQueryString="false" type="Rewrite" url="/public/api.php?app=search&q={R:1}"/> </rule> <rule name="searchapi_rewrite" stopProcessing="true"> <match ignoreCase="false" url="^search/(.*)/(.*)$"/> <action appendQueryString="false" type="Rewrite" url="/public/api.php?app=search&q={R:1}&page={R:2}"/> </rule> </rules>