通过url/regex_url和rewrite_not_exist配合使用,能够实现绝大多数伪静态功能。本节将以Wordpress和discuz为例,给出典型的app.conf配置示例。
如没有app.conf文件可在桌面建立文件通过FTP上传网站根目录。
wordpress
如果wordpress设置为“朴素”方式,则app.conf不需要进行其他处理。如果为其他方式,则需要在app.conf中加入以下规则:
- rewrite_not_exist: (.*)
script: /index.php/$1
完整的app.conf文件内容如下:
handlers:
- url : /
script : /index.php
script : /index.html
- rewrite_not_exist: (.*)
script: /index.php/$1
- errordoc : 404 /error/404.html
- expire : .jpg modify 10 years
- expire : .swf modify 10 years
- expire : .png modify 10 years
- expire : .gif modify 10 years
- expire : .JPG modify 10 years
- expire : .ico modify 10 years
discuz
如果用户部署的是discuz,建议在app.conf中加入以下规则:
- regex_url: ^/topic-(.+).html$
script: /portal.php?mod=topic&topic=$1&%1
- regex_url: ^/article-([0-9]+)-([0-9]+).html$
script: /portal.php?mod=view&aid=$1&page=$2&%1
- regex_url: ^/forum-(w+)-([0-9]+).html$
script: /forum.php?mod=forumdisplay&fid=$1&page=$2&%1
- regex_url: ^/thread-([0-9]+)-([0-9]+)-([0-9]+).html$
script: /forum.php?mod=viewthread&tid=$1&extra=page%3D$3&page=$2&%1
- regex_url: ^/group-([0-9]+)-([0-9]+).html$
script: /forum.php?mod=group&fid=$1&page=$2&%1
- regex_url: ^/space-(username|uid)-(.+).html$
script: /home.php?mod=space&$1=$2&%1
- regex_url: ^/blog-([0-9]+)-([0-9]+).html$
script: /home.php?mod=space&uid=$1&do=blog&id=$2&%1
- regex_url: ^/archiver/(fid|tid)-([0-9]+).html$
script: /archiver/index.php?action=$1&value=$2&%1
- regex_url: ^/([a-z]+[a-z0-9_]*)-([a-z0-9_-]+).html$
script: /plugin.php?id=$1:$2&%1
完整的app.conf内容如下:
handlers:
- url : /
script : /index.php
script : /index.html
- regex_url: ^/topic-(.+).html$
script: /portal.php?mod=topic&topic=$1&%1
- regex_url: ^/article-([0-9]+)-([0-9]+).html$
script: /portal.php?mod=view&aid=$1&page=$2&%1
- regex_url: ^/forum-(w+)-([0-9]+).html$
script: /forum.php?mod=forumdisplay&fid=$1&page=$2&%1
- regex_url: ^/thread-([0-9]+)-([0-9]+)-([0-9]+).html$
script: /forum.php?mod=viewthread&tid=$1&extra=page%3D$3&page=$2&%1
- regex_url: ^/group-([0-9]+)-([0-9]+).html$
script: /forum.php?mod=group&fid=$1&page=$2&%1
- regex_url: ^/space-(username|uid)-(.+).html$
script: /home.php?mod=space&$1=$2&%1
- regex_url: ^/blog-([0-9]+)-([0-9]+).html$
script: /home.php?mod=space&uid=$1&do=blog&id=$2&%1
- regex_url: ^/archiver/(fid|tid)-([0-9]+).html$
script: /archiver/index.php?action=$1&value=$2&%1
- regex_url: ^/([a-z]+[a-z0-9_]*)-([a-z0-9_-]+).html$
script: /plugin.php?id=$1:$2&%1
- errordoc : 404 /error/404.html
- expire : .jpg modify 10 years
- expire : .swf modify 10 years
- expire : .png modify 10 years
- expire : .gif modify 10 years
- expire : .JPG modify 10 years
- expire : .ico modify 10 years
答案文章来源:http://abcfund.cc/1698.html
也可以参考百度官方来源:https://bce.baidu.com/doc/BCH/GettingStarted/37.5C.E4.BC.AA.E9.9D.99.E6.80.81URLRewrite.E7.A4.BA.E4.BE.8B.html
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)