我们做PHP开发的,作者寒冰我觉得大部分时候都在跟开源的系统打交道。比如:Discuz、PHPCMS、ecshop、wordpress等开源系统。一般我们都是在本地搭建测试环境,用的web服务器都是apache。这时候假如服务器换成了nginx。我们得重新写重写文件,好麻烦。

鉴于此需求点,今天寒冰我特意整理了这些开源的重写文件。希望能帮到大家。

1、PHPCMS v9重写。

rewrite ^/show-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3;
rewrite ^/content-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3;
rewrite ^/list-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=lists&catid=$1&page=$2;
rewrite ^/tag-([^\.]*)-([0-9]+)-([0-9]+).html /index.php?m=content&c=tag&catid=$2&tag=$1&page=$3;
rewrite ^/comment-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=comment&c=index&a=init&commentid=content_$1-$2-$3;

2、discuz 7.2重写:

rewrite ^(.*)/archiver/((fid|tid)-[\w\-]+\.html)$ $1/archiver/index.php?$2 last;
rewrite ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&page=$3 last;
rewrite ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^(.*)/profile-(username|uid)-(.+)\.html$ $1/viewpro.php?$2=$3 last;
rewrite ^(.*)/space-(username|uid)-(.+)\.html$ $1/space.php?$2=$3 last;
rewrite ^(.*)/tag-(.+)\.html$ $1/tag.php?name=$2 last;

3、discuz x2系列重写:

rewrite ^(.*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^(.*)/article-([0-9]+)\.html$ $1/portal.php?mod=article&articleid=$2 last;
rewrite ^(.*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^(.*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^(.*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^(.*)/([a-z]+)-(.+)\.html$ $1/$2.php?rewrite=$3 last;

4、ecshop重写:

rewrite ^/index\.html /index.php last;
rewrite ^/category$ /index.php last;
rewrite ^/feed-c([0-9]+)\.xml$ /feed.php?cat=$1 last;
rewrite ^/feed-b([0-9]+)\.xml$ /feed.php?brand=$1 last;
rewrite ^/feed\.xml$ /feed.php last;
rewrite ^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 last;
rewrite ^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$ /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5 last;
rewrite ^/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ /category.php?id=$1&brand=$2&page=$3&sort=$4&order=$5 last;
rewrite ^/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$ /category.php?id=$1&brand=$2&page=$3 last;
rewrite ^/category-([0-9]+)-b([0-9]+)(.*)\.html$ /category.php?id=$1&brand=$2 last;
rewrite ^/category-([0-9]+)(.*)\.html$ /category.php?id=$1 last;
rewrite ^/goods-([0-9]+)(.*)\.html /goods.php?id=$1 last;
rewrite ^/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ /article_cat.php?id=$1&page=$2&sort=$3&order=$4 last;
rewrite ^/article_cat-([0-9]+)-([0-9]+)(.*)\.html$ /article_cat.php?id=$1&page=$2 last;
rewrite ^/article_cat-([0-9]+)(.*)\.html$ /article_cat.php?id=$1 last;
rewrite ^/article-([0-9]+)(.*)\.html$ /article.php?id=$1 last;
rewrite ^/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html /brand.php?id=$1&cat=$2&page=$3&sort=$4&order=$5 last;
rewrite ^/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html /brand.php?id=$1&cat=$2&page=$3 last;
rewrite ^/brand-([0-9]+)-c([0-9]+)(.*)\.html /brand.php?id=$1&cat=$2 last;
rewrite ^/brand-([0-9]+)(.*)\.html /brand.php?id=$1 last;
rewrite ^/tag-(.*)\.html /search.php?keywords=$1 last;
rewrite ^/snatch-([0-9]+)\.html$ /snatch.php?id=$1 last;
rewrite ^/group_buy-([0-9]+)\.html$ /group_buy.php?act=view&id=$1 last;
rewrite ^/auction-([0-9]+)\.html$ /auction.php?act=view&id=$1 last;
rewrite ^/exchange-id([0-9]+)(.*)\.html$ /exchange.php?id=$1&act=view last;
rewrite ^/exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ /exchange.php?cat_id=$1&integral_min=$2&integral_max=$3&page=$4&sort=$5&order=$6 last;
rewrite ^/exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ /exchange.php?cat_id=$1&page=$2&sort=$3&order=$4 last;
rewrite ^/exchange-([0-9]+)-([0-9]+)(.*)\.html$ /exchange.php?cat_id=$1&page=$2 last;
rewrite ^/exchange-([0-9]+)(.*)\.html$ /exchange.php?cat_id=$1 last;

5、phpwind重写:

rewrite ^(.*)-htm-(.*)$ $1.php?$2 last;
rewrite ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 last;
rewrite ^(.*)/data/(.*)\.(htm|php)$ 404.html last;
rewrite ^(.*)/attachment/(.*)\.(htm|php)$ 404.html last;
rewrite ^(.*)/html/(.*)\.(htm|php)$ 404.html last;

6、shopex重写:

rewrite ^/(.+\.(html|xml|json|htm|php|jsp|asp|shtml))$ /index.php?$1 last;

7、wordpress重写:

location / {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}

8、typecho 重写:

location / {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}

原文:http://www.phpcxz.com/archives/nginx_vhosts_rewrite.html

Nginx环境下常见的开源项目重写汇总的更多相关文章

  1. nginx环境下配置nagios-关于nagios配置文件nginx.conf

    接上文:nginx环境下配置nagios-关于nginx.conf 配置如下: ;          location ~ .*\.(php|php5)?$          {            ...

  2. nginx环境下配置nagiosQL-关于nagiosql配置文件

    接上文:nginx环境下配置nagios-关于nginx.conf nagiosql文件应该处于conf/domain/目录下 nagiosql配置如下: ;                  gzi ...

  3. Nginx环境下配置PHP使用的SSL认证(https)

    最近一段时间发现好多网站都从http协议变成了加密的https协议,比如说百度.吾志等等.https看起来比http高端了好多,而且在不同的浏览器向上还会显示出不同于http的URL展示效果(比如说c ...

  4. 【thinkphp 5 在nginx 环境下路由无法生效(404 500错误 )的解决方法】

      非常惭愧的说,由于之前一直使用的是windowservice,安装apache来进行服务器布置的,这种方式也是最简单最直接的方式, 但是由于php的服务大多都是linux栈的,咱们也不能落后呀,在 ...

  5. 【简书】在阿里云自带的CentOS + LAMP环境下部署一个Laravel项目

    在阿里云自带的CentOS + LAMP环境下部署一个Laravel项目 作者 DonnieZero 关注 2017.07.29 22:02* 字数 2218 阅读 5556评论 3喜欢 1赞赏 1 ...

  6. nginx环境下启动php-fpm

    nginx环境下启动php-fpm 1.首先查看是否安装了php-fpm 这个我试了好多命令都不行比如 rpm -qa php-fpm , rpm -ql php-fpm , which php-fp ...

  7. CI在nginx环境下去掉url中的index.php

    在nginx环境下CI框架默认URL规则访问不了,出现500错误,如: http://blog.php230.com/index.php/keywords 今天在服务器配置CI框架环境时,去除URL中 ...

  8. Nginx环境下设置zblog伪静态方法

    Apache的环境非常简单.可以点击创建 .htaccess就可以了 Nginx环境下设置伪静态,并没有那个一键创建的按钮.只看到了这样的一个提示. 别的环境未测试.宝塔面板中 反正我是没找到. 宝塔 ...

  9. Nginx环境下,PHP下载,中文文件,下载失效(英文可以下载)怎么解决呢?

    参考出处: http://www.imooc.com/qadetail/76393 Nginx环境下,PHP下载,中文文件,下载失效(英文可以下载)怎么解决呢? 背景介绍: 文件名  为英文时可以下载 ...

随机推荐

  1. 柯里化(Curing)

    柯里化:把接受多个参数的函数变换成接受单个参数的函数,并且返回准备接受余下参数,还能返回结果的一种技术. function currying(fn){ var args = Array.prototy ...

  2. JavaScript语言内置对象

    String(字符串对象)RegExp(正则表达式对象)Number(数字对象)Math(数学对象)Function(函数对象)Error(异常对象)Date(日期/时间对象)Boolean(布尔对象 ...

  3. 【Maven实战】依赖的聚合和版本管理

    1.在之前的文章中,我们已经建立了四个Maven项目,但是此时如果我们要对这四个项目进行编译打包时,必须一个一个的进行执行命令,而聚合就是指只要我们在其中一个项目中编写一些代码,则在进行此项目的编译和 ...

  4. Milking Grid

    poj2185:http://poj.org/problem?id=2185 题意:在一个字符矩阵中,找一个最小的字符子矩阵,使其能够覆盖整个矩阵. 题解:在KMP中i-next[i]是这能够覆盖这个 ...

  5. Linux定时运行与开机运行任务

    http://os.51cto.com/art/200805/75144.htm at命令与crontab命令 http://os.51cto.com/art/201007/211874.htm ht ...

  6. mybatis insertUseGeneratedKeys

    mybatis中的一个坑:预期:传入的Record中会生动填入在db中生成的id值. 使用  insertUseGeneratedKeys插入数据时,如果id字段不是AUTO_INCREMENT,则不 ...

  7. sql union代替or

    ---原始SQL SQL> SELECT deptno FROM emp WHERE empno = 7788 OR job = 'SALESMAN' ORDER BY 1; DEPTNO -- ...

  8. BZOJ1596: [Usaco2008 Jan]电话网络

    1596: [Usaco2008 Jan]电话网络 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 513  Solved: 232[Submit][S ...

  9. BZOJ1660: [Usaco2006 Nov]Bad Hair Day 乱发节

    1660: [Usaco2006 Nov]Bad Hair Day 乱发节 Time Limit: 2 Sec  Memory Limit: 64 MBSubmit: 606  Solved: 289 ...

  10. 【转】两分钟彻底让你明白Android Activity生命周期(图文)!----不错

    原文网址:http://blog.csdn.net/android_tutor/article/details/5772285 大家好,今天给大家详解一下Android中Activity的生命周期,我 ...