ICMS>正文
icms栏目/文章/标签等应用 Rewrite规则示例
2019-01-29 12:44 gblrewrite 规则
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; ##栏目 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; ##标签 使用标签所属栏目规则 /{CDIR}/{TKEY}{EXT}, ##当前TKEY生成是没有分隔符的 所以用w+匹配 ##如果有分隔符的话,要把分隔符也在加规则里去 ##例如:([w-]+) -为分隔符 rewrite "^/.+/([w-]+).html$" /tag.php?tkey=$1 last; rewrite "^/.+/([w-]+)_(d+).html$" /tag.php?tkey=$1&page=$2 last;
如果程序安装在网站根目录的话
由于后台编辑器上的链接分别为/app/admincp/ui/ueditor/dialogs/image/image.html
/app/admincp/ui/ueditor/dialogs/video/video.html
会被上面的标签伪静态规则匹配到,造成显示404或者显示找不到该标签
那么就将标签的伪静态规则改成如下
rewrite "^/(?!app/admincp).+/([w-]+).html$" /tag.php?tkey=$1 last; rewrite "^/(?!app/admincp).+/([w-]+)_(d+).html$" /tag.php?tkey=$1&page=$2 last;
apache
RewriteEngine on RewriteBase / ##文章 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] ##标签 使用标签所属栏目规则 /{CDIR}/{TKEY}{EXT}, ##当前TKEY生成是没有分隔符的 所以用w+匹配 ##如果有分隔符的话,要把分隔符也在加规则里去 ##例如:([w-]+) -为分隔符 RewriteRule ^/.+/([w-]+).html$ tag.php?tkey=$1 last; RewriteRule ^/.+/([w-]+)_(d+).html$ tag.php?tkey=$1&page=$2 last;
IIS (未测试正确性,如有问题请自行修改)
<rule name="文章规则1" stopProcessing="true"> <match url="^w+/d+/d+/(d+).html$" ignoreCase="false" /> <action type="Rewrite" url="article.php?id={R:1}" appendQueryString="false" /> </rule> <rule name="文章规则2" stopProcessing="true"> <match url="^w+/d+/d+/(d+)_(d+).html$" ignoreCase="false" /> <action type="Rewrite" url="article.php?id={R:1}&p={R:2}" appendQueryString="false" /> </rule> <rule name="栏目1" stopProcessing="true"> <match url="^(w+)/$" ignoreCase="false" /> <action type="Rewrite" url="category.php?dir={R:1}" appendQueryString="false" /> </rule> <rule name="栏目2" stopProcessing="true"> <match url="^(w+)/index.html$" ignoreCase="false" /> <action type="Rewrite" url="category.php?dir={R:1}" appendQueryString="false" /> </rule> <rule name="栏目3" stopProcessing="true"> <match url="^(w+)/index_(d+).html$" ignoreCase="false" /> <action type="Rewrite" url="category.php?dir={R:1}&page={R:2}" appendQueryString="false" /> </rule> <rule name="标签规则1" stopProcessing="true"> <match url="^.+/([w-]+).html$" ignoreCase="false" /> <action type="Rewrite" url="tag.php?tkey={R:1}" appendQueryString="false" /> </rule> <rule name="标签规则2" stopProcessing="true"> <match url="^.+/([w-]+)_(d+).html$" ignoreCase="false" /> <action type="Rewrite" url="tag.php?tkey={R:1}&page={R:2}" appendQueryString="false" /> </rule>
本文链接:https://www.0937.biz/post-367.html
猜你喜欢
- 2019-01-29 Notepad++ 批量修改文件编码格式
- 2019-01-29 如何防止网站被恶意镜像?
- 2019-01-29 ICMS常用标签
- 2019-01-29 ICMS MySQL数据表的MyISAM转换成InnoDB引擎的两种方法
- 2019-01-29 ICMS数据表大全
- 2019-01-29 MySQL的MyISAM转换成InnoDB引擎的两种方法
- 2019-01-29 iCMS通用rewrite伪静态规则
- 2019-01-29 icms标签大全
- 2019-01-29 请问title调用分页页码?用什么标签 ICMS
- 01-29icms栏目/文章/标签等应用 Rewrite规则示例
- 07-14MySQL的MyISAM转换成InnoDB引擎的两种方法
- 07-08请问title调用分页页码?用什么标签 ICMS
- 07-08icms标签大全
- 07-14iCMS通用rewrite伪静态规则
- 03-22你不能访问此共享文件夹,因为你组织的安全策略...
- 09-30ICMS常用标签
- 11-19如何防止网站被恶意镜像?
- 09-30ICMS常用标签
- 11-13ICMS MySQL数据表的MyISAM转换成InnoDB引擎的两...
- 11-13ICMS数据表大全
- 07-14MySQL的MyISAM转换成InnoDB引擎的两种方法
- 07-14iCMS通用rewrite伪静态规则
- 07-08icms标签大全
- 11-19如何防止网站被恶意镜像?
- 09-30ICMS常用标签
- 11-13ICMS MySQL数据表的MyISAM转换成InnoDB引擎的两...
- 11-13ICMS数据表大全
- 07-14MySQL的MyISAM转换成InnoDB引擎的两种方法
- 07-14iCMS通用rewrite伪静态规则
- 07-08icms标签大全
- 热门标签